Originally asked by Jose Lobo on 23 September 2020 (original question)
How can I get incident.caller_id = replica.reporter on both sides of the integration (Jira - ServiceNow)
Originally asked by Jose Lobo on 23 September 2020 (original question)
How can I get incident.caller_id = replica.reporter on both sides of the integration (Jira - ServiceNow)
Answer by André Leroy-Beaulieu Castro on 23 September 2020
Hi!
This can be achieved with the following scripts:
Sync Reporter from Jira to Caller ID in ServiceNow:
Outgoing Sync Jira:
replica.reporter = issue.reporter
Incoming Sync ServiceNow:
incident.caller_id = nodeHelper.getUserByEmail(replica.reporter?.email)?.key
Sync Caller ID from ServiceNow to Reporter on Jira:
Outgoing Sync ServiceNow:
if(!(incident.caller_id instanceof String)){
replica.callerMail = nodeHelper.getTableByLink(incident.caller_id?.link)?.email
}
Incoming Sync Jira:
issue.reporter = nodeHelper.getUserByEmail(replica.callerMail)
Keep in mind that this will only work if the reporters have the same e-mail on both sides.
If the reporters have different e-mails on each side, you can use a mapping to map between users like so:
Incoming Sync:
def userMapping = ["snowuser@example.com":"jirauser@example.com"]
issue.reporter = nodeHelper.getUserByEmail(userMapping[replica.callerMail])
Another option if you don’t want to map users would be to try to find a user with the same e-mail as the source side in the destination, and if it’s not found, then set a default user:
Incoming Sync:
def defaultUser = nodeHelper.getUserByEmail("defaultuser@example.com")
issue.reporter = nodeHelper.getUserByEmail(replica.callerMail) ?: defaultUser
Thanks,
André
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.