Force update if no value change

Hafsa1
Mega Sage

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?

8 REPLIES 8

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.

 

Hafsa1
Mega Sage

There is 1 field out of 4 which we are hardcoding in script. So in this case also setForceUpdate(true) will work?

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?

Hafsa1
Mega Sage

other 3 are directly coming from source application