Sync Agile Accelerator custom objects from Salesforce to Jira (included threaded comments)

Originally asked by Syed Majid Hassan on 05 October 2022 (original question)


Requirements:

  • Sync Work items from Agile Accelerator module from Salesforce to Jira issues
  • Ensure that the threaded comments on the Work in Salesforce and synced to jira

Answer by Syed Majid Hassan on 05 October 2022

Please use the following code snippet on the Salesforce outgoing script to ensure that the threaded replies are sent over as well:

Expand source

if(entity.entityType == "agf__ADM_Work__c") {
replica.key            = entity.Id
replica.summary        = entity.agf__Subject__c
replica.description    = entity.Description
replica.comments       = entity.comments.findAll {
    comment ->
    def res = httpClient.get("/services/data/v54.0/query/?q=SELECT+Name+from+User+where+id=%27${comment.author.key}%27")
    comment.body = nodeHelper.stripHtml(res.records.Name[0] + ": " + comment.body)
}
replica.attachments    = entity.attachments
replica.Status         = entity.Status

//Get the threadedComments of all chatter threads in this Work
def threadedComments = httpClient.get("/services/data/v54.0/query/?q=SELECT+Id%2CCommentBody%2CInsertedById+from+FeedComment+where+ParentId=%27${entity.Id}%27")

//For each threadedComment, read all the replies and append usernames to it
//Create a comment object with this info and add to the replica
for(int i=0; i<threadedComments.records.size(); i++){
        def res = httpClient.get("/services/data/v54.0/query/?q=SELECT+Name+from+User+where+id=%27${threadedComments.records[i].InsertedById}%27")
        def c = new com.exalate.basic.domain.hubobject.v1.BasicHubComment()
        c.body = res.records.Name[0] + " commented--: " + nodeHelper.stripHtml(threadedComments.records[i].CommentBody)
        c.id = threadedComments.records[i].Id
        replica.comments += c
        }
}

Please check out the explaining how this works:

Agile Accelerator Threaded replies SF JIRA.mp4 (old community)

Thanks

Majid


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.