2 answers
- 10-1
The final scripts are here in full:
Here is a SF Jira - Threads + User mentions.mp4 of the use cases covered above.
Thanks
Majid
Add your comment... - 10-1
Thanks for the direction here Serhiy Onyshchenko !
The code that I have come up with is the following:
if(entity.entityType == "Case") { replica.key = entity.Id replica.summary = entity.Subject replica.description = entity.Description replica.attachments = entity.attachments replica.Status = entity.Status //Pick up normal SF chatter comments and append the username of the commenter 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) } //Get the feed-element-id of all chatter threads in this case def feedIds = httpClient.get("/services/data/v54.0/query/?q=SELECT+id+from+CaseFeed+where+ParentId=%27${entity.Id}%27") //For each chatter thread, read all the replies and append usernames to it for(int i=0; i<feedIds.records.size(); i++){ def feedResponse = httpClient.getResponse("/services/data/v54.0/chatter/feed-elements/${feedIds.records[i].Id}") def js = new groovy.json.JsonSlurper() def feedJson = groovy.json.JsonOutput.toJson(feedResponse.body) feedResponse.body.capabilities.comments.page.items.collect { def res = httpClient.get("/services/data/v54.0/query/?q=SELECT+Name+from+User+where+id=%27${it.user.id}%27") def c = new com.exalate.basic.domain.hubobject.v1.BasicHubComment() c.body = res.records.Name[0] + " commented: " + it.body.text c.id = it.id replica.comments += c } } }
This is working perfectly for sending threaded replies as well as normal comments.
Please let me know your thoughts here.
Thanks
Majid
- Stéphane Thillay
Hi Majid,
This script works and is useful.
I'm wondering what is the purpose of the line "
def js =
new
groovy.json.JsonSlurper()
"?My groovy skill is poor so I may miss the point. It looks like a variable/instance of a class, but it is not used elsewhere in the script.
Regards,
Stéphane
- Syed Majid Hassan
Good catch Stéphane Thillay ,
I believe it was there to parse the response as part of the debugging effort needed in developing the script.
Add your comment...
When syncing chatter feed comments from SF to Jira, the threaded replies in SF are not included in the replica and hence, never sent to Jira. Can you please help with this?
Hey, Syed Majid Hassan
I've added this to the outgoing sync script:
where 0D57Q00000Pf2DiSAJ is an id of a comment:
and here's the error produced:
You may then inject through the list of comments on an entity, fetch sub-comments via httpClient and then
turn them into a
Happy Exalating!
add them to the injected result