Jira Integration with Salesforce Flow and Apex

Incoming support Cases from customers from a Postal Service company were integrated with Jira for further internal processing.

Jonathan Taroco
3 min readApr 18, 2023

First of all, authentication. An External Credential was created to be used as Basic Authentication. More information here.

External Credential

An After Save Record-Triggered Flow was created to filter only the necessary incoming Cases and trigger an Autolaunched Flow to set the Jira information and its consequently call.

After Save Record-Triggered Flow

After defining specific essential information to create the Jira ticket, an Apex Class is called through a Flow Apex Action.

Flow Apex Action

The invocable Apex Class is a global one having an @InvocableMethod which receives a list of the FlowInput wrapper below, sent by the mentioned Autolaunched Flow.

Variables used by a Flow

In order to create the correct JSON Request as provided by the official documentation here, we can create the body by instantiating the FlowInput variables with the values received by the Flow and encapsulating them in a wrapper class that represents the necessary Jira JSON Request, used by JiraService.createPOSTBody().

Example

The method createPOSTBody() receives the FlowInput variables coming from the Flow to create the Jira JSON Request.

Apex Wrapper representing the JSON Request to create a Jira issue

Note that some information was created as custom fields in Jira:
The Salesforce information ‘clientNr’ is represented by ‘customfield_10078’ in Jira.

clientNr: customfield_10078
typeSupportContract: customfield_10080
accountURL: customfield_10125
caseURL: customfield_10124

Doing this, the method createPOSTBody() returns the necessary Jira JSON Request that will be used as the body of the Http Request in our Apex Class.

Jira JSON Request in Postman

As result, once a Case meets the criteria to be synchronized with Jira, we can see that created in Jira.

The Jira ticket can also be updated, the API Response has a ‘key’ with the corresponding Jira reference, here and here. When we receive a successful creation, this ‘key’ is saved in an external unique Salesforce Id field. The same After Save Flow can identify updates and triggers a Jira update.

  • Create issue: /rest/api/2/issue
  • Update issue: /rest/api/2/issue/{issueKey}
Jira ticket

--

--

Jonathan Taroco

Salesforce Developer | Application Architect | Sharing personal notes and projects