Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

update() function not actually updating record

dstuart
Kilo Expert

I have a script to copy data from certain fields on CI records, and then clear the 'source' fields. I had the script working a few months ago, but it 'got lost' during a clone/upgrade process. Now, I am trying to recreate it, without success.

The problem is the update() function is not actually updating the record.

According to the SN Docs site, Update() will return the sys_id of the record on a successful update. And I do get the sys_id back from the update() call.

However, if I then display the record's sys_updated_on (last Updated) field, it has not changed. It still shows the pre-update date and time. And the field data updates made by the script are not there.

This is happening on two different instances, so I don't believe it's something unique to an instance. More likely, it's something in my script. But my fellow admins and I an't find anything wrong.

Ideas as to what to look for? I'm attaching the complete script for your reference.

Thanks,

Dave

6 REPLIES 6

Goran,



setForceUpdate(true) will do what I want, but thinking about it, I think there's a better way...



Thanks for the ideas and suggestions.




Dave


Thanks for the ideas Goran,



I got looking again at the data to be updated, and I was able to filter it down even further. Instead of the 50K record on my first pass, I;m down to about 9,000 records that actually require an update. The others don't really meet the requirements for updating. My error.



Dave