GlideRecord - setWorkFlow(Boolean e)

Enables or disables the running of business rules that might normally be triggered by subsequent actions. If the e parameter is set to false, an insert/update will not be audited. Auditing only happens when the parameter is set to true for a GlideRecord operation.

Note: The setWorkFlow() method is ignored when subsequently using either the deleteProblem() or deleteMultiple() methods to cascade delete.
Table 1. Parameters
Name Type Description
e Boolean If true (default) enables business rules, and if false to disables them.
Table 2. Returns
Type Description
void

Scoped equivalent

To use the setWorkFlow() method in a scoped application, use the corresponding scoped method: Scoped GlideRecord - setWorkflow(Boolean enable).

doit('name1','name2'); 
 
function doit(username1,username2) { 
 
  var usr1 = new GlideRecord('sys_user');
  var usr2 = new GlideRecord('sys_user');
  var num = 0;
 
  if (usr1.get('user_name',username1) && usr2.get('user_name',username2)) {
    var ref;
    var dict = new GlideRecord('sys_dictionary');
    dict.addQuery('reference','sys_user');
    dict.addQuery('internal_type','reference');
    dict.query();
    while (dict.next()) {
      num = 0;
      ref = new GlideRecord(dict.name.toString());
      ref.addQuery(dict.element,usr1.sys_id);
      ref.query();
      while (ref.next()) {
        ref.setValue(dict.element.toString(),usr2.sys_id); 
        ref.setWorkflow(false);
        ref.update();
        num++;
      }
      if (num > 0) {
        gs.print(dict.element + ' changed from ' + usr1.user_name + 
          ' to ' + usr2.user_name + ' in ' + num + ' ' + dict.name + ' records');
      }
    }
  }
}