Originally asked by Jose Lobo on 23 September 2020 (original question)
How do I sync Jira Cloud reporter and assignee fields to SNow Change Request requested_by and assigned_to fields respectively?
Originally asked by Jose Lobo on 23 September 2020 (original question)
How do I sync Jira Cloud reporter and assignee fields to SNow Change Request requested_by and assigned_to fields respectively?
Answer by André Leroy-Beaulieu Castro on 23 September 2020
Hi,
Thanks for raising this community question.
Jira Outgoing Sync:
replica.assignee = issue.assignee
replica.reporter = issue.reporter
ServiceNow Incoming Sync (When Reporter/Assignee have the same e-mail on Jira and SNOW):
changeRequest.assigned_to = nodeHelper.getUserByEmail(replica.assignee?.email)?.key
changeRequest.requested_by = nodeHelper.getUserByEmail(replica.reporter?.email)?.key
ServiceNow Incoming Sync (When Reporter/Assignee have different e-mails on Jira and Snow):
def userMapping = ["jirauser@example.com":"servicenowuser@example.com"]
changeRequest.assigned_to = nodeHelper.getUserByEmail(userMapping[replica.assignee?.email])?.key
changeRequest.requested_by = nodeHelper.getUserByEmail(userMapping[replica.reporter?.email])?.key
Thanks,
André
This isn’t working Andre. I’m getting “Script error details: No such property: changerequest for class: Script8. Error line: Script8.groovy:12”
That was a type
changerequest
should be:
changeRequest
I will edit the comment
Didn’t see that either. Ok I made the change and it works for changeRequest. However, I’m trying to use the same method to populate a catalogTask and it only partially works.
ServiceNow incoming sync looks like this:
catalogTask.assigned_to = nodeHelper.getUserByEmail(replica.assignee?.email)?.key
catalogTask.u_affected_user = nodeHelper.getUserByEmail(replica.reporter?.email)?.key
“Assigned_to” populates fine but “u_affected_user” does not. Affected User is a custom field but it references the sys_user table just like assigned_to. What might the problem be?
Could it be that the replica reporter didn’t contain a valid user on service now system? Exalate uses this API to find the user:
/api/now/v2/table/sys_user?email=$email
You might try to use that on your browser (in front of the servicenow url) using the email you are receiving from the other side. To know which email you are getting exactly, you might use the Entity Sync Status page, where you can input the catalog task number and get the “remote replica” (that’s the last replica received from the other side, which you deal with on the incoming)
No the user email is definitely in SNow user table. It’s the same user that populates fine for the change request requested_by field. It’s just not working for the catalog task u_affected_user field.
and the api call is definitely returning results from a browser session as well. Just tested with multiple users.
That’s very odd. Exalate would just generate a json that would look like:
{
"u_affected_user" : "$user_sys_id"
}
To make the update. The fact that is working on assigned_to with the same user indicates that the sys_id should be found. I think at this point I would try:
def localReporter = nodeHelper.getUserByEmail(replica.reporter?.email)?.key
if(localReporter){
throw new Exception("Local reporter is id is "+localReporter)
}
Make a sync from the other side, and see if the error appears, it should appear if the user is found.
We can set up a screen sharing call to debug this as well, feel free to contact us for that.
Best regards,
Juan
Hi Juan. Screen sharing session is a great idea. When might you be available for this? I have a block of time on Monday from 12-3 eastern if anywhere in there works for you. Let me know.
Answer by Angelo Surian on 07 October 2020
Worked with Juan to figure this out and there was nothing wrong with the way Exalate was trying to populate the ServiceNow field. It ended up being a business rule on the SNow side that was overwriting the field after Exalate populated it so it looked like it never populated it to begin with.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.