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.
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?
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?
Hi Benjamin,
It depends on the actual field type / name. For example, if you are syncing "Assignee" this should work:
Or you can receive a customField value as an example:
Kind regards,
Ariel
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:
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?
Hi Ben,
This is good.
Kind regards,
Ariel