Retrospectively updating records without changing the "Updated" field?

howard8
Tera Contributor

Hi All,

 

We use the date value of "updated" field (global) for reporting (e.g. Finding incidents that are open but haven't been updated in a month), but I need to retrospectively correct a field on thousands of records that has been calculating incorrectly. I don't want the "updated" value to change just because I am correcting erroneous data.   If I just run a simple script to fix the values, the update fields will all change, and all of the reports would not work anymore.

 

I looked for some sort of global business rule that manages the updating of this value, so I could briefly turn it off, but no luck.

 

Does anyone know a way of doing a mass update to a table without changing the "updated" field?

 

Thanks

 

Howard Elton

Service Transformation Manager

Synergy Energy

1 ACCEPTED SOLUTION

Jim Coyne
Kilo Patron

Take a look at this great article on GlideRecords - http://www.servicenowguru.com/scripting/gliderecord-query-cheat-sheet/



Look at the "setWorkflow" and "autoSysFields" methods in particular.


View solution in original post

5 REPLIES 5

Jim Coyne
Kilo Patron

Take a look at this great article on GlideRecords - http://www.servicenowguru.com/scripting/gliderecord-query-cheat-sheet/



Look at the "setWorkflow" and "autoSysFields" methods in particular.


howard8
Tera Contributor

Thanks very much for that!



So the key is to use "autoSysFields(false)" in you query like this:



//Change the category of all 'software' incidents to 'hardware' without updating sys fields


var gr = new GlideRecord('incident');


gr.addQuery('category', 'software');


gr.query();


while(gr.next()){


    gr.category = 'hardware';


    gr.autoSysFields(false);


    gr.update();


}




Perfect.


Correct.   And I always use "setWorkflow(false)" as well just to make sure the update does not kickoff any other Business Rules that might send out an email, etc...


HI JIm



I had a similar request , the autoSysfield has not showing latest update in history log , audit . but i keep updating the details to update field( sys_updated_on)


we need , sys_updated_on not wants to update if any changes happened in the asset table last scan field