Transform Script - fdlGitHub/ServiceNow GitHub Wiki
autoSysFields onBefore
To prevent the automatic setting of the system fields (like sys_created_on, sys_updated_by, etc), the setting as a Field Map is not enough. An onBefore script is needed with the following line:
target.autoSysFields(false);
Ignore onBefore
if(action == "update") {
ignore = true;
}
Ignore onAfter
When a line is ignore, transform script onAfter is always executed. To skip the execution of the transform script use the following code :
if(source.getValue("sys_import_state") === 'ignored')
return;
Service Now Documentation Import Set onAfter script runs for ignored rows during transformation
Action for Inserted or Updated records
A specific action can be done for only inserted or updated records. For that we have to use the following code :
if(source.getValue("sys_import_state") === 'inserted') {
// do an action on inserted records
}
else if(source.getValue("sys_import_state") === 'updated') {
// do an action on updated records
}