Originally asked by Stéphane Thillay on 27 June 2023 (original question)
Hi,
In a Salesforce to Jira on premise connection, we must prevent the synchronisation because the Salesforce Case lacks some fields we need before creating a Jira issue.
Our core need is to have the “Connect” button only on Salesforce.
It comes via the Exalate component, with the “Exalate” button.
So we want to behave safely if anyone press this “Exalate” button, that means raise a warning and do nothing.
On Salesforce, the Exalate component is displayed, showing the “Exalate” and “Connect” buttons. This component is here only for the “Connect” button but, unless we can get rid of the “Exalate” button, we have to set some safety rules. If a user press the “Exalate” button, that starts a synchronisation that never complete because on Jira side the issue creation is failing, because of missing/null values.
We don’t want to create new Issue with default values, they must come from Salesforce side.
We want to halt the synchronisation as early as possible.
We are thinking of some check in the outgoing script on Salesforce side, that detect the empty field and give up the synchronisation (that would otherwise be an error on Jira side).
In the Salesforce outgoing script, we tried things like:
if (entity.JiraProject__c?.value == null) {
throw new Exception("No Jira Project selected, aborting.")
}
or
if (entity.JiraProject__c?.value == null) {
return
}
The first one leaves a blocking error on the connection. The second generates no outcome but the status on the case is “WAITING_FOR_REMOTE”. In both cases pressing the “Exalate” button result in a green Toaster message.
What could be the solution?
Regards,
Stéphane
Comments:
Stéphane Thillay commented on 27 June 2023
Here is the steps that drove us to our current question.
- we have a trigger that start synchronisation (SF Case to new Jira Issue) when specific Case fields are populated (those used to fulfil the new Jira Issue)
- Users ask to connect SF Case to existing Jira Issue
- We add the Exalate component on Case page to get the “Connect” button
- We can’t get rid of the “Exalate” button from the same component
- We look for a way to make the “Exalate” button without effect, in case a user clicks it by mistake
- We tried to throw an exception, a bare return and now an assert. Nothing fits.