...
...
...
...
Sending notifications based on a Project's notification scheme
The All recipients of Issue Commented event setting allows you to enable email notifications
...
defined within your Jira's Notification Scheme.
The event that is triggered is the Issue Commented event and is dependent on the Notification Scheme that is set up for the project
...
to which the Connection is bound
...
.
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 Deploying Apex documentation).
Notifying Jira of new comments on Cases
This provides notifications when someone creates a comment in Salesforce.
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:
Adding CaseComment trigger
Cloud
The JCFS.API.fireEvents() API endpoint allows Jira to be notified of events happening in Salesforce, typically originating from Salesforce triggers.
Call JCFS.API.fireEvents() in an after insert Trigger on CaseComment as follows:
Notify JIRA of new comments on Cases
Code Block | ||
---|---|---|
| ||
trigger CaseCommentsCreated on CaseComment (after insert) {
JCFS.API.fireEvents(JCFS.Events.fromCreatedCaseComments(Trigger.new));
} |
If you don't
...
want to send all triggered CaseComment objects to Jira, you can
...
pass a filtered List<CaseComment> to JCFS.Events.fromCaseComments().
Server
The JSFS.API.fireEvents() API endpoint allows Jira to be notified of events happening in Salesforce, typically originating from Salesforce triggers.
Call JSFS.API.fireEvents() in an after insert Trigger on CaseComment as follows:
Notify JIRA of new comments on Cases
Code Block | ||
---|---|---|
| ||
trigger CaseCommentsCreated on CaseComment (after insert) {
JSFS.API.fireEvents(JSFS.Events.fromCreatedCaseComments(Trigger.new));
} |
If you don't
...
want to send all triggered CaseComment objects to Jira, you can simply pass a filtered List<CaseComment> to JSFS.Events.fromCaseComments().
Testing CaseComment trigger
To get test coverage for CaseComment trigger use the provided test helper as shown:
Cloud
Apex test class for CaseComment trigger
Code Block | ||
---|---|---|
| ||
@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 | ||
---|---|---|
| ||
@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);
}
} |
Advanced information
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:
Code Block |
---|
Method defined as TestMethod do not support Web service callouts |
...
To fix this error, you need to specify a fake response for the callouts. JiraTriggerTestHelper
already provides a mock for its test method, but it will not mock other webservice callouts. Therefore, you may need to provide your own implementation of HttpCalloutMock.
...
Customize the following code according to your callout method:
SuccessCalloutMock
Code Block | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
@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();
}
}
|
For more details, please refer to
...
the Salesforce Testing HTTP Callouts documentation.