Force update if no value change
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2020 09:50 PM
I'm fetching custom table record using SOAP message and calling it form scheduled script.
It runs every 3 days and update/insert record in custom table which is having only 100-150 records. Now most of the records don't get changed frequently is source application, hence, it don't update record in servicenow. But we have a requirement that it should update all records every 3 days irrespective of whether record value get changed or not.
Can anyone suggest what to use in scheduled script to force update every record?
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2020 10:47 PM
Hi Hafsa,
If you are reading all 110 records and updating them without any check, then using setForceUpdate(true) shall work.
But when you are updating, are you setting any values in those records? if yes, will those value come from your source application or are you going to hardcode it? Kindly check that.
I don't understand the logic behind updating the record when there is no change done. Later it will be difficult to know whether the update is made because or change or not. It is not recommended.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2020 11:01 PM
There is 1 field out of 4 which we are hardcoding in script. So in this case also setForceUpdate(true) will work?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2020 11:04 PM
setForceupdate(true) basically updates the record irrespective of any change done or not. It will be something liek this
gr.setForceUpdate(true); //Force an update even with no changes gr.update();
If you are hardcoding only 1 value, what about the other 3 values? how are you setting the other 3 values?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2020 11:27 PM
other 3 are directly coming from source application