Script not working

sunil10
Tera Contributor

Hi all

I am using below business rule on user table after update and active changes to false, everything is working fine state getting update worknotes getting updated but autosysfields not working, please suggest

 

(function executeRule(current, previous /*null when async*/ ) {


    var grScReqItem = new GlideRecord('sc_req_item');
    grScReqItem.addEncodedQuery("cat_item=32524947c32b9a1062c17ebdc00131a5^stateNOT IN3,4,7^requested_for=" + current.sys_id);
    grScReqItem.query();
    while (grScReqItem.next()) {
 
        grScReqItem.setWorkflow(false);
         grScReqItem.autoSysFields(false);
 
        grScReqItem.work_notes = "RITM is closed incomplete as the requestor has been deactivated.";
        grScReqItem.state = "4";
        grScReqItem.update();
    }
})(current, previous);
12 REPLIES 12

Brad Bowman
Kilo Patron
Kilo Patron

To clarify, are you saying that you don't want fields like updated by and updated on (or which fields specifically) to be updated when this rule triggers but they are getting updated, or they aren't updated and you want them to be updated?

@Brad Bowman  

Script is working fine as required only issue i am facing is when worknotes and state getting update it is showing my name instead system

sunil10
Tera Contributor

sunil10_0-1741613763070.png

 

autoSysFields(false) disables updates to sys_updated_by, sys_updated_on, sys_mod_count, sys_created_by, and sys_created_on fields, which is not necessarily the same as something appearing in the activity stream.  Can you confirm on the updated record that these fields were or or not updated with the change?