How to auto-associate a Salesforce record with a Jira issue upon Jira issue creation in Jira Cloud

How to auto-associate a Salesforce record with a Jira issue upon Jira issue creation in Jira Cloud

Problem

Currently, the connector cannot automatically link a Salesforce Object with a Jira issue at the moment the Jira issue is created. However, by leveraging the capabilities of the Jira REST API, you can implement automation within the project to facilitate the auto-association process.

To make the automation work, manually add the Salesforce Object ID in a custom field when creating the Jira issue. This method is also compatible with Jira Service Management (JSM).

This guide focuses exclusively on one-to-one associations.

Instructions

Part 1: Create a Jira Custom Field

Jira Automation allows us to automatically send a web request to edit the entity property of the Jira issue and then associate the Salesforce record.

  1. In Jira, go to Settings > Work Items > Fields > Create new field:

    1. Field type: Short Text (plain text only)

    2. Name: In this example, the name of the field is Case ID.

  2. Add this field to your Create screen for the relevant Issue Type.

  3. (Optional) Add the field to the View and Edit screens.

Part 2: Creating the Jira Automation

Jira Automation allows us to automatically send a web request to edit the entity property of the Jira issue and then associate the Salesforce record.

  1. Go to Project > Project Settings > Automation (in the left panel).

  2. Click Create Rule.

  3. In the first component, select the Field value changed option and set it as follows:

    • Fields to monitor for changes: Case ID

    • Change type: Any changes to the field value

    • For: Create issue

Field value changed screen with Fields to monitor for changes, Change type and For fields
  1. Click Add Component > IF: Add a condition > {{smart values}} condition. This ensures that our agents/customers add the correct ID of the configured object. In this example, the Case Object type is used.

    • First value: {{issue.<customField_Id>}}

    • Condition: Starts with

    • Second Value: Object ID prefix

Ensure you utilize the field ID corresponding to the field you created on your instance in Part 1 of this documentation. To find the Custom Field ID, refer to How to find the ID for custom field(s).

The Salesforce Object Key Prefix List | Salesforce Bendocumentation provides information to help identify the prefix of the object you'll be working with.

smart values condition page with First value, Condition, and Second value fields
  1. Click Next, then Add an action > Create variable and set the component as follows:

    • Variable name: CaseID

    • Smart value: {{fieldChange.toString}}

This helps update the JSON file in the web request.

Create variable screen with Variable name and Smart value fields
  1. Click Next > Add Component > IF: Add a condition > {{smart values}} condition and set the component as follows:

    • First value: {{CaseID.length()}}

    • Condition: equals

    • Second value: 18

This helps to verify that the added ID is the correct length.

smart values condition screen with First value, condition and Second value fields
  1. Set the Web Request URL with the URL according to your Jira environment:

    • Jira Cloud EU: eu-sfjc.integration.appfire.app/external/api/association?allowUpsert=true

    • Jira Cloud Rest of the World: https://sfjc.integration.appfire.app/external/api/association?allowUpsert=true

  2. In a new tab, navigate to Jira > Apps > Connector for Salesforce > Connections > click the 3 dots next to your connection > API Access Token > Select the REST API token lifespan and copy the token shown at the bottom.

    image-20250722-141733.png
  3. Go back to the automation and in the Headers section, set the Key name as Authorization.

  4. Set the Value as JWT <REST API Token>

  5. Set the HTTP Method to POST and select the Delay execution option.

  6. Set the Web Request body as Custom data and use the following JSON file in the Custom data field. In this example, a case object type is used.

    { "jiraIssueId": "{{issue.id}}", "son": "Case", "soid": "{{CaseID}}", "viewOnly": false, "autoPush": true, "autoPull": true }

    The web request component up to this point looks like the following:

    image-20250722-142144.png

     

  7. Click Next > Add Component > THEN: Add an action > Re-fetch issue data.

Overview of the final automation:

image-20250723-134035.png

Now, if you add the Salesforce Object ID within the Case ID field after creating a Jira issue, the automation associates that record with the created Jira issue.

This auto-association won’t trigger the default post-actions; you’ll need to manually push the information to Salesforce.