1
0
-1

I'm trying to get the current value of a field of the issue I'm going to sync to in an incoming sync in ServiceNow, because I want to compare it with the value that is coming in from the other (source) side.


I tried to use incident.assigned_to, as this is what I would use to set the new value, so I thought it might contain the old value before that. But it seems to only work in one direction.


Is there any other way I can do that?

  1. Ariel Aguilar

    Hi Benjamin, 

    It depends on the actual field type / name. For example, if you are syncing "Assignee" this should work:

    if(entityType == "incident") {
      incident.assigned_to = nodeHelper.getUserByEmail(replica.assignee?.email)?.key  
    }

    Or you can receive a customField value as an example:

    if(entityType == "incident") {
      incident.assigned_to = replica.customFields."Jira Field Name"?.value
    }

    Kind regards,

    Ariel

  2. Benjamin Kiene

    Thank you, Ariel, for your feedback, but maybe I wasn't clear enough.


    I wanted the current value of the destination before applying the source to it and it seems like


    oldValue = incident.assigned_to


    doesn't do it.


    The only idea that I could come up with is to use the nodeHelper.getReference function to get the current value of the destination record. Like so:


    currentAssignedTo = nodeHelper.getReference("incident", "number", incidentNumer).assigned_to.value
    
    newAssignedTo = nodeHelper.getUserByEmail(replica.assignee?.email)?.key
    
    // Now I can do something like
    
    if (currentAssignedTo != newAssignedTo) {
    	//do something here
    }

    I haven't tested it yet, but I'm pretty sure that should work.


    Or does anybody know a better way to get this current value of the destination?

  3. Ariel Aguilar

    Hi Ben,

    This is good.

    Kind regards,

    Ariel

CommentAdd your comment...