Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The setup consists of two parts:

  1. Specifying Jira groups to notify, in Jira.

  2. Creating and deploying required Apex triggers, in Salesforce.

At the moment, the Connector supports sending email notifications to Jira users when someone creates a Case comment.

...

Jira groups can be specified at the Connection level. This affects each binding and Jira project that is using the Connection.

  1. Go to Settings > Apps, and then in the sidebar, under Salesforce, choose Connections.

  2. At the Salesforce Connections screen, go to the Connection you want to configure > Configure.

  3. Under Notification Settings, choose who you want to send notifications to by selecting All recipients of Issue Commented eventCurrent Assignee, Reporter, All Watchers, All Voters and/or Groups.
    For more information about All recipients of Issue Commented event, see "Sending Notifications Based on a Project's Notification Scheme".

...

  1. Image Added



  2. Click Save.

Sending notifications based on a Project's notification scheme

...

Do take note that only the following recipients are supported: 

  • Current Assignee

  • Reporter

  • Single User 

  • Group

  • All Watchers

Creating and deploying Apex triggers

The Connector relies on Apex triggers to be informed of changes on Salesforce objects. These triggers have to be created and deployed manually in Salesforce.

For Salesforce Enterprise and Unlimited editions, the standard deployment of Apex triggers are required (see Salesforce documentation).

...

Note that the email notification will be sent:

  • Based on the  Comment Privacy and Comment Tag Filter settings in the Connection configuration page.

  • Only to Jira issues currently associated with the Case.

  • Only to Jira users (in the specified groups) who have access to the associated Jira issue.

A successful email notification may look like this:Image Removed

...

Adding CaseComment trigger

...

Call JCFS.API.fireEvents() in an after insert Trigger on CaseComment as follows:

...

...

Notify JIRA of new comments on Cases
linenumbers
Code Block
languagetruejava
trigger CaseCommentsCreated on CaseComment (after insert) {
	JCFS.API.fireEvents(JCFS.Events.fromCreatedCaseComments(Trigger.new));
}

...

Call JSFS.API.fireEvents() in an after insert Trigger on CaseComment as follows:

...

Notify JIRA of new comments on Cases
Code Block
linenumberslanguagetruejava
trigger CaseCommentsCreated on CaseComment (after insert) {
	JSFS.API.fireEvents(JSFS.Events.fromCreatedCaseComments(Trigger.new)); 
}

...

To get test coverage for CaseComment trigger use the provided test helper as shown:

Cloud

...

...

Apex test class for CaseComment trigger
Code Block
linenumberslanguagetruejava
@isTest public class CaseCommentCreatedTriggerTest {
	@isTest static void caseCommentAfterInsertTest() {
		Case randomCase = new Case(Subject = 'CaseCommentCreatedTriggerTest');
		insert randomCase;
		CaseComment randomCaseComment = new CaseComment(
			ParentId = randomCase.Id,
			CommentBody = 'In faucibus orci est, vitae dignissim enim commodo a.'
		);
		JCFS.JiraTriggerTestHelper.testAfterInsert(randomCaseComment);
	}
}

Server

...

Apex test class for CaseComment trigger
Code Block
linenumberslanguagetruejava
@isTest public class CaseCommentCreatedTriggerTest {
    @isTest static void caseCommentAfterInsertTest() {
        Case randomCase = new Case(Subject = 'CaseCommentCreatedTriggerTest');
        insert randomCase;
        CaseComment randomCaseComment = new CaseComment(
            ParentId = randomCase.Id,
            CommentBody = 'In faucibus orci est, vitae dignissim enim commodo a.'
        );
        JSFS.JiraTriggerTestHelper.testAfterInsert(randomCaseComment);
    }
}

...

If you have other triggers with Webservice callouts that are executed as a result of running this test, you might get an error message like this:

No Formatcode
Method defined as TestMethod do not support Web service callouts

...

Please customize the following code according to your callout method:

SuccessCalloutMock
Code Block
title
languagejavaSuccessCalloutMock
public class SuccessCalloutMock implements HttpCalloutMock {
    public HTTPResponse respond(HTTPRequest req) {
        HttpResponse response = new HttpResponse();
        response.setStatusCode(200);
        return response;
    }
}

Then, set the mock before the CaseCommentCreatedTriggerTest test method is called.

CaseCommentCreatedTriggerTest
Code Block
languagejavatitleCaseCommentCreatedTriggerTest
@isTest public class CaseCommentCreatedTriggerTest {
    @isTest static void caseAfterInsertTest() {
        Test.setMock(HttpCalloutMock.class, new SuccessCalloutMock());
        Case randomCase = new Case(Subject = 'CaseCommentCreatedTriggerTest');
		insert randomCase;
		CaseComment randomCaseComment = new CaseComment(
			ParentId = randomCase.Id,
			CommentBody = 'In faucibus orci est, vitae dignissim enim commodo a.'
		);
        Test.startTest();
        insert randomCaseComment;
        Test.stopTest();
    }
}

...