Skip to content

Instantly share code, notes, and snippets.

@eduglez
Created May 31, 2019 12:55
Show Gist options
  • Save eduglez/764bf868f3161c7629946ad42e717787 to your computer and use it in GitHub Desktop.
Save eduglez/764bf868f3161c7629946ad42e717787 to your computer and use it in GitHub Desktop.
ServiceNow - Duplicate Transform Maps
(function(sourceMapSysId, targetMapSysId, targetTableName){
var grNewMap = new GlideRecord('sys_transform_map');
if(!grNewMap.get(targetMapSysId)){
return;
}
var grOriginalMap = new GlideRecord('sys_transform_map');
if(!grOriginalMap.get(sourceMapSysId)){
return;
}
var grEntry = new GlideRecord('sys_transform_entry');
grEntry.addQuery('map', grOriginalMap.getUniqueValue());
grEntry.query();
while (grEntry.next()) {
grEntry.map = grNewMap.getUniqueValue();
grEntry.source_table = targetTableName;
grEntry.insert();
}
var grScript = new GlideRecord('sys_transform_script')
grScript.addQuery('map', grOriginalMap.getUniqueValue());
grScript.query();
while (grScript.next()) {
grScript.map = grNewMap.getUniqueValue();
grScript.insert();
}
})('eb70312bdb375700782ded6b4b9619ee', '715fa1c3db91b300039f1bbf29961903', 'u_packaging_historical_data'); // Sys Id's of the transform maps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment