Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ServiceNow background script to check import transform map choice actions
//change to sysid of app you want to scan
var appID = "e32a61c94f198a004f167d2ca310c72a";
reviewTransformChoiceActionsForApp(appID);
function reviewTransformChoiceActionsForApp(appId) {
var entry = new GlideRecord("sys_transform_entry");
entry.addQuery("sys_scope", appId);
entry.orderBy("map");
entry.query();
while (entry.next()) {
targetTable = entry.getValue("target_table");
targetField = entry.getValue("target_field");
var choiceFieldType = getChoiceFieldType(targetTable, targetField);
if (!choiceFieldType)
continue;
gs.info("{0} - {1}.{2} ({3}), {4}", entry.map.getDisplayValue(), targetTable, targetField, choiceFieldType, entry.getValue("choice_action"));
}
}
function getChoiceFieldType(table, element) {
var gr = new GlideRecord(table);
gr.initialize();
var el = gr.getElement(element);
var internalType = j2js(el.getED().getInternalType());
if (internalType == "reference")
return "reference";
if (internalType == "choice" || (internalType == "string" && j2js(el.getChoices()).length > 0)) {
return "choice";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.