mikeski.net kotlin java javascript hugo development

mikeski.net development blog

Enable auditing for tables with a script

If we need to enable auditing for a bunch of scoped app tables, we can use a script.

Note that if we name tables consistently it makes things much easier to script.

Code

Here’s the code:

 var gr = new GlideRecord('sys_dictionary');
 gr.addQuery('sys_name', 'STARTSWITH', 'x_myapp_nma')
 gr.query();
 while(gr.next()){
   if(gr.getValue("sys_name").toString().indexOf("import_document") == - 1){
  		gs.debug("Found: " + gr.getValue("sys_name") + " audit: " + gr.getValue("audit")); 
     gr.setValue("audit", true);
     gr.update();
   }
 }
 
 gr;

 

Note that we are querying for tables that start with the x_myapp_nma custom scope prefix . This also ignores tables with import_document in the name.