The latest release of IBM® App Connect provides enhanced support for Jira Service Desk – a Service desk and ticketing platform for IT teams. With the enhanced support, App Connect users can integrate more features of Jira Service Desk into their workflows.

(Click image to view full size)

Connecting to Jira Service Desk

Connect App Connect to Jira Service Desk by providing the following connection information. This enables App Connect to use Jira Service Desk functionality.

  • User name: The user name that you use to log in to Jira Service Desk.
  • Password: The password or API token of your account. Preferred authentication is with an API token.
  • Server URL: The domain-specific Jira Service Desk server URL that you use to log in to the Service Desk portal. For example, if your domain is xxx, the server URL would be: https://xxx.atlassian.net.

(Click image to view full size)

You can connect either from the Applications tab on the App Connect Catalog page, or when you add the app to a flow.

Scenario

In this example, we describe a data sync scenario where newly created or updated cases are retrieve every one hour and then create or update corresponding issues in Jira Service Desk. The flow is trigger for every case object

This example assumes that we have already connected App Connect to Salesforce and Jira Service Desk, and have started to create a new event-driven flow (by clicking New > Event-driven flow on the App Connect dashboard).

Before you start designing your flow, in order to establish sync between two applications we need to define relationship between them. So, in Salesforce application you can easily establish that relationship using external ids. Here for this example, we have created a custom external id field called ‘external_id__c’ in the Salesforce.

To start the flow, let’s add a configurable polling event for Salesforce, which will trigger the flow every hour. To choose Salesforce polling events, scroll down to Salesforce, expand its list and then click Configure more events. In the panel, expand Cases and then click New or updated Cases.

(Click image to view full size)

The polling event requires us to configure some properties. (We’ve explained each configuration property briefly in Configuring polled events to trigger flows.) The Salesforce event provides default values for most of the properties, but we need to ensure that we set a polling interval to the required value. So let’s set the Check for new ‘Case’ every (minutes) property to 60, to poll every hour. (Tip: For testing, we can set the property to a shorter interval.) This will check Salesforce for any newly created Cases or updated Cases every hour for last hour and triggers the flow for each event that has happened in the Salesforce.

(Click image to view full size)

Now let’s start adding actions to the flow. The final goal of the actions is to create an issue if it is a new Case or update the issue if it is an existing updated Case. So we are implementing two scenario in single flow.
To find whether an event that has triggered is new or updated Case we rely on external id value. If external id field i.e external_id__c contains the Jira issue id means the Case already synced and there is a corresponding issue in Jira instance. If external id is empty that means its a new Case and corresponding issue needs to be created in Jira. Once issue is created in Jira we go back and update the issue id as external id value for the Case in Salesforce.

So first node on action is “If node”. The “If node” determines whether the Case event that is triggered is for create or update. And it uses “external_id__c” property in the Case event object.

Here the “If node” is checking for external_id__c is empty or not. If external_id__c value empty then its create scenario and else part i.e non empty value is an update scenario. All the actions needs to be performed to create an issue are done in “if” branch and all the actions needs to be performed to update an issue are done in “else” branch.

To create an issue in Jira, we need the following mandatory information:

  • Issue Type: The ID reference to a Jira issue type like ‘Bug’, ‘Epic’, and so on
  • Priority: The ID reference to a Jira priority type like ‘High’ or ‘Medium’
  • Project: The ID reference to a Jira project to which the issue needs to refer

So before we create an issue, we need to retrieve the above information from Jira Service Desk. App Connect provides corresponding retrieve actions for all of the above. Let’s look at how to retrieve issue types from the Jira server. In our flow, we add a Jira Service Desk “Retrieve issue types” action, and set the maximum number of retrieved items to 20; this will be used to retrieve all issue types available in the Jira server.

(Click image to view full size)

Now let’s retrieve all priority types available in the Jira server by adding a Jira Service Desk “Retrieve priorities” action. Again, we set the maximum number of items to retrieve to 20.

(Click image to view full size)

Next, let’s retrieve the project that we want to assign new issues to by adding a Jira Service Desk “Retrieve projects” action. We use a Where clause that retrieves project information based on the project name, and set the maximum items to retrieve to 1.

(Click image to view full size)

Now that we have all the mandatory information to create a Jira issue, we can add a Jira Service Desk “Create issue” action.

  1. In the mandatory Summary field, map to the Salesforce / Case > Subject value.
  2. In the Issue Type / ID field, map to the issue type that was returned by the Jira Service Desk / Retrieve issue types action, and use JSONata to filter from the array of issue types. For example, we can use the following JSONata expression to retrieve the ID of issue type ‘Task’:
    {{$AtlassianJIRAServiceDeskRetrieveissuetypes[name='Task'].id}}

    (Read more about using JSONata in Applying JSONata functions.)

  3. In the Priority / ID field, map to the priority retrieved from the Jira Service Desk / Retrieve priorities action, and apply the following JSONata expression (where $Trigger.Priority identifies the priority retrieved):
    {{$JiraServiceDeskRetrievepriorities[name=$Trigger.Priority].id}}
  4. In the Project / ID field, map to the project ID from Jira Service Desk / Retrieve projects, and use the following JSONata expression to obtain the first object from the projects array:
    {{$JiraServiceDeskRetrieveprojects[0].id}}

(Click image to view full size)

As part of create issue scenario we need to go back and update the Salesforce Case with the issue id created. This is how we establish the relation between a Case and an Issue. So you need to add and configure Salesforce “Update case” action.

Note: Map the external_id__c field with the the issue Id that is returned from Jira Service Desk/ Create issue action.

Now that we have completed if branch for create issue scenario, lets see how to do update issue scenario in else branch.

The else branch will have only single action i.e Jira Service desk Update issue action. To update an issue in Jira we need its id, the external_id__c field from Case event object will have the issue id that should be used. Map the filter Id with the value of external_id__c field returned by Salesforce / New or updated Cases trigger. We are updating Summary and Description here but you can map all relevant fields.

Now the flow is ready to be started. The flow checks Salesforce every hour for any new cases, and then creates a corresponding issue in Jira.

(Click image to view full size)

If you’d like to try out this scenario, you can sign up to App Connect and get started in minutes. Here’s the flow definition file (Sync Salesforce Case with Jira Issue.yaml) for you to import and use as a template to create your own flow.

Join The Discussion

Your email address will not be published. Required fields are marked *