1
0
-1

How do I sync Jira Cloud reporter and assignee fields to SNow Change Request requested_by and assigned_to fields respectively?

    CommentAdd your comment...

    2 answers

    1.  
      2
      1
      0

      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é

      1. Angelo Surian

        This isn't working Andre. I'm getting "Script error details: No such property: changerequest for class: Script8. Error line: Script8.groovy:12"

      2. Juan Grases

        That was a type 

        changerequest

        should be:
        changeRequest

        I will edit the comment

      3. Angelo Surian

        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?

      4. Juan Grases

        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)

      5. Angelo Surian

        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.

      6. Angelo Surian

        and the api call is definitely returning results from a browser session as well. Just tested with multiple users.

      7. Juan Grases

        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:


        1. Try to update this field from Postman and see what works
        2. Make extra sure that's the exact name of the field
        3. To make extra sure that the replica.reporter?.email returns a valid user I would do something like:
        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

      8. Angelo Surian

        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.

      CommentAdd your comment...
    2.  
      2
      1
      0

      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.

        CommentAdd your comment...