Cloud Migration Resources
Planning a Jira Cloud migration? These resources can help you get started:
→ Connector for Salesforce & Jira Cloud features – Review Cloud features and understand key differences between DC and Cloud.
→ Migration support from Appfire – Learn how we can help you migrate smoothly.
Associate Jira work item with Salesforce records and trigger post actions automatically
Overview
Salesforce Apex API methods allow for associating a Jira work item with a Salesforce record or a list of Salesforce records and triggering a default action that happens immediately after an association. This simplifies the process of integrating Salesforce with Jira by eliminating the need for custom API code.
associateJiraIssue- associates a Jira work item with a list of Salesforce records, for example, cases, accounts, or contacts. It doesn’t trigger default post-actions after the association.Syntax:
associateJiraIssue(String jiraKey, List<SObject> sObjects)Parameters:
jiraKey: The Jira work item keysObject: A type of Salesforce object for the records you want to associate with the specified Jira work item. To learn more aboutsObject, see the Salesfors developers documentation.
associateJiraIssueWithDefaultPostActions- associates a Jira work item with a list of Salesforce records and triggers default post-action. Administrators can configure the default action that happens immediately after an association in the Connections settings.Syntax:
associateJiraIssueWithDefaultPostActions(String jiraKey, List<SObject> sObjects)Parameters:
jiraKey: The key of the Jira work item.sObject: A type of Salesforce object for the records you want to associate with the Jira work item. To learn more aboutsObject, see the Salesforse developers documentation.
These methods eliminate the need for complex custom code when interacting with Jira endpoints to update associations.
Before you start
Ensure that the Jira work item key provided is valid and accessible using the connected Jira instance (set up a connection to Salesforce, bind a project to a connection).
Configure the default post-actions triggered by
associateJiraIssueWithDefaultPostActionsin the Connections setup in the Jira-Salesforce integration. Configure connection settings after Associating.
Instructions
In Salesforce, in the upper right corner, click the gear icon (
) and select Setup.
In the Quick Find box, type
Apex Triggers.Click Developer Console on the Apex Triggers screen.
On the Developer Console screen, select File > New > Appex Trigger.
Fill in Apex Trigger details:
For example:
Name:AssociateOnCreate
sObject: Case - Select the Salesforce Object type you want to associate from the list.Click Submit.
Paste the Apex Trigger into the code console.
Example Apex Trigger
Here is an example of using associateJiraIssueWithDefaultPostActions in an Apex trigger to associate a Jira work item with newly created Salesforce cases:
Jira Cloud
trigger AssociateOnCreate on Case (after insert) {
JCFS.API.associateJiraIssueWithDefaultPostActions('S8U-8', Trigger.new);
}