Synchronize comment author from Salesforce to Jira

Originally asked by Andres Martynowicz on 23 March 2022 (original question)


We’re trying to sync a case comment author from Salesforce to Jira Cloud but it’s not working as the author is always “Exalate”.

I’ve followed the documentation to add this code :

issue.comments = commentHelper.mergeComments(issue, replica){ it.executor = nodeHelper.getUserByEmail(it.author?.email) }

I’ve also made sure that the comment author exists on Jira and has the permissions to access the project and add comments.

Please advise.


Answer by Ariel Aguilar on 26 March 2022

Hi Andres,

I was able to reproduce the problem from Salesforce to Jira Cloud:

To achieve what is needed, you will need to inspect the local replica from Salesforce side, and you will get something like:

“comments”: [
{
“id”: “00a5f000000oZGfAAM”,
“author”: {
“key”: “0055f000000xGlUAAU”,
“active”: false
},
“body”: “TEST internal comment.”,
“created”: 1648252800000,
“internal”: true,
“restrictSync”: false
}

Then, once you know the author key, what you will need is to define a user mapping:

final def userMapping = [
      "0055f000000xGlUAAU" : "ariel.aguilar@idalko.com"
]
issue.comments = commentHelper.mergeComments(
  issue,
  replica,
  {
    it.executor = nodeHelper.getUserByEmail(userMapping[it.author?.key]);it
  }
)

I just tested it and it worked for me.

Kind regards,

Ariel