Skip to content

Instantly share code, notes, and snippets.

@jlrjr
Last active April 28, 2016 22:19
Show Gist options
  • Save jlrjr/649203eb8332edbea98f72642bcdb751 to your computer and use it in GitHub Desktop.
Save jlrjr/649203eb8332edbea98f72642bcdb751 to your computer and use it in GitHub Desktop.
Reset all records in an ServiceNow application to a given vendor or user name
//run in global scope as background script
/**** set these variables before running ****/
var vendorName = "--CAVUCode--";
var appID = "---AddAppSysIDHere---";
/**** after setting variabless above, uncomment this line to run ****/
//updateAppFiles(vendorName, appID);
function updateAppFiles(vendorName, appID) {
var gr = new GlideRecord("sys_metadata");
gr.addQuery("sys_scope", appID);
gr.addQuery("sys_updated_by", "!=", vendorName);
gr.orderBy("sys_class_name");
gr.orderBy("name");
gr.query();
gs.print(gr.getRowCount());
while (gr.next()) {
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.sys_created_by = vendorName;
gr.sys_updated_by = vendorName;
gr.update();
gs.print("Updated " + gr.getDisplayValue("sys_class_name") + ": " + gr.getDisplayValue());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment