...
Adding CaseComment trigger
...
deckId | AddingCaseCommentTrigger |
---|
...
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:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
trigger CaseCommentsCreated on CaseComment (after insert) {
JCFS.API.fireEvents(JCFS.Events.fromCreatedCaseComments(Trigger.new));
} |
If you don't wish to send all triggered CaseComment objects to Jira, you can simply 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:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
trigger CaseCommentsCreated on CaseComment (after insert) {
JSFS.API.fireEvents(JSFS.Events.fromCreatedCaseComments(Trigger.new));
} |
If you don't wish 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
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
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); } } |
...