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

felixs
Tera Expert

Hello,



I know this post is marked as answered, but I found myself having to dig quite a bit to find out how to do this via a Transform Map. So Im piggy-backing this thread in order to spread some knowledge.



Edit: I have found and confirmed a very simple solution that is scalable:


I have confirmed that you can update system fields such as sys_updated_by and most other sys_ fields using a Transform Map with minimal Script. My instance is currently a Fuji release.



1. Create your Transform Map like normal with your source table, target table, and all of your fields mapped like normal.


2. Check the "Run business rules" box so that it remains unchecked.


3. Check the "Run script" box so that it remains checked.


4. In the script box make sure to add:


  1. //Make sure update is only done on existing records  
  2. if ( action == "insert") {  
  3.       ignore = true;  
  4. }  
  5. /* Disable SN from auto updating sys_fields */  
  6. //Needed in order to leave historical information unchanged  
  7. target.autoSysFields(false);  
  8. //Disable the running of business rules that might normally be triggered by SN.  
  9. target.setWorkflow(false);  

5. At the bottom left, in the Field Maps tab/list, create a new field map


Screen Shot 2016-07-14 at 5.51.26 PM.png


Create a new mapping from your target import table to your sys_ field that you want to update


6. Save, upload your data, and run your transform.



Hope that helps someone out there!



You can also find a method using Glide Records here: https://community.servicenow.com/thread/162539