Configuring Automatic Jira Issue Creation from Salesforce

This guide will help you to configure Automatic Jira issue creation from Salesforce by configuring the required Salesforce triggers. If you haven't done so, configure the available objects and fields before proceeding with the following steps. The Salesforce Package must be installed and configured as well.

Note that Automatic Jira issue creation will work only if:

  • Salesforce objects, from which you want to create Jira issues automatically, are configured to be available for the authorized connection.
  • Apex triggers for the respective objects are installed.

Create and Deploy Apex triggers

You need Apex triggers to automatically create Jira issues from Salesforce objects. These triggers have to be created and deployed manually in Salesforce. For Salesforce Enterprise and Unlimited edition, the standard deployment of Apex triggers are required (see Salesforce documentation).

The following code samples show how to write triggers for Cases. To create triggers for other objects, replace the object name in the code accordingly.

Automatically Create Jira issue after a Salesforce Object in inserted

trigger CaseInsertedTrigger on Case (after insert) {
    JCFS.API.createJiraIssue('1000', '10002');

Note that you need to, respectively, hardcode the Jira project id and Jira issue type id. You can get this values from the Jira REST API. In future versions of the package, there will be a feature helping admins generate the full code for the trigger from a template.

Automatically Create Jira issue after a Salesforce Object in updated

You can also create an issue automatically after an object is updated (e. g. in an after update trigger) as follows:

trigger CaseUpdatedTrigger on Case (after update) {
    JCFS.API.createJiraIssue('1000', '10002');


The above-mentioned method works only if you call the API directly from within a trigger. If you need to call the API indirectly, for instance from a helper method, see the advanced usage section below.

Apex test class for the triggers

Once triggers are created, they need a certain level of test coverage to be allowed to deploy to the Production environment. The package contains a test helper which tests the whole scenario. You simply need to add a unit test for each trigger and call the test helper method. Depending on the trigger event (after insert or after update) you will have to call the corresponding test helper method. A sample of both tests are shown in the following example:

@isTest public class CaseTriggerTest {
    @isTest static void caseAfterInsertTest() {
	@isTest static void caseAfterUpdateTest() {

Just as the trigger itself, you need a test for each object trigger. All you have to do is replace Case in the above code with the actual object name.

Custom objects

The Apex API and test helper methods work as well with any custom object. You just need to find out the object name (e.g. 'MyObject__c') and use it in the trigger code as documented above. If you are testing a Custom Object, provide the fully qualified name (include your namespace in the Salesforce Object Name, e. g. 'yournamespace__MyObject__c')

Advanced usage

Our Apex API supports selective issue creation, so that you can avoid automatic creation of Jira issues from unwanted Salesforce objects. For this purpose you can use the following API method:

Signature of JCFS.API.createJiraIssue
JCFS.API.createJiraIssue(String JiraProjectId, String JiraIssueTypeId, List<SObject> newObjects, List<SObject> oldObjects)

Pass all the objects you want to create a Jira issue from as newObjects. Note that all the objects in this list must be of the same runtime type. So we recommend to use a concrete type, e.g. List<Case> or List<Account> for the variable you pass as this parameter. The oldObjects parameter is not used at the moment so you can pass Trigger.old or an empty list for it.

For instance, if you want to create Jira issues only from Cases whose summaries start with Post you can use the following trigger code:

Selective automatic JIRA issue creation
trigger CaseInsertedTrigger on Case (after insert) {
    List<Case> toBeCreated = new List<Case>(); // proper runtime type, List<SObject> won't work
    for(Case c : {
        if(c.Subject.startsWithIgnoreCase('Post')) {
    JCFS.API.createJiraIssue('10300', '10001', toBeCreated, Trigger.old);