Last active
          April 28, 2016 22:19 
        
      - 
      
 - 
        
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
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | //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