- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2024 08:04 AM
Hi,
Why not to use Setlimit method while using updatemultiple.
Needs to know why setLimit() is not allowed on updatemultiple() method.
I have checked the Servicenow Documentation it has been mentioned as below
This method sets new values and does not clear existing values. To clear an existing value, use the setValue() method and set the field to null.
I need more clarification for this. Couldn't find a y detailed document for this.
Share the details if you any idea.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2024 11:42 AM - edited 10-06-2024 11:54 AM
Hi @VasukiS ,
updateMultiple() or deleteMultiple() works on the entire glide query result set. That is why if you see you don't even fetch each record by iterating through the object using 'next()' inside a loop before executing updateMultiple() or deleteMultiple(). You just query and put updateMultiple() or deleteMultiple() since it works like you are telling system to update or delete all the records in the result set at once (not, one by one by looping through each record).
updateMultiple() is also much more efficient than (update()) looping through each record returned from your glide query, retrieving it from the database, setting each value at a time, and saving each record back to the database.
As updateMultiple() or deleteMultiple() works on entire result of the glide query by its working mechanism, there is no point of using chooseWindow() or setLimit() before, as those will be just ignored even if you put those before updateMultiple() and deleteMultiple().
If this address your question, please mark this response correct by clicking on Accept as Solution and/or Kudos.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2024 11:42 AM - edited 10-06-2024 11:54 AM
Hi @VasukiS ,
updateMultiple() or deleteMultiple() works on the entire glide query result set. That is why if you see you don't even fetch each record by iterating through the object using 'next()' inside a loop before executing updateMultiple() or deleteMultiple(). You just query and put updateMultiple() or deleteMultiple() since it works like you are telling system to update or delete all the records in the result set at once (not, one by one by looping through each record).
updateMultiple() is also much more efficient than (update()) looping through each record returned from your glide query, retrieving it from the database, setting each value at a time, and saving each record back to the database.
As updateMultiple() or deleteMultiple() works on entire result of the glide query by its working mechanism, there is no point of using chooseWindow() or setLimit() before, as those will be just ignored even if you put those before updateMultiple() and deleteMultiple().
If this address your question, please mark this response correct by clicking on Accept as Solution and/or Kudos.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das