Scheduled Script is updating only 1 record each runtime, not mutliple records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2023 10:13 PM
I have the below scheduled script with the objective of updating multiple records that match the given criteria.
It is scheduled to execute every 10 seconds.
In Run As field, I have given my name (I have admin access).
The script text of above screenshot is also given below:
var gr = new GlideRecord("cmdb_ci_service");
gr.addEncodedQuery(
"service_classification=Project^end_date<javascript:gs.beginningOfToday()"
);
gr.query();
while (gr.next()) {
gr.setValue('operational_status', '6');
gr.update();
}
But what is happening is, each time only 1 record is getting updated.
If I manually click Execute Now, then also only 1 record (1st record of GR object) is getting updated, but the rest are remaining with old value of the operational status field.
Please help me to identify what is the issue here.
Please mark this post as a solution and also as helpful, if this resolves your issue or query.
Thanks,
Subhadeep Ghosh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 02:54 AM
Thank you so much @OlaN for taking so much of your time and sharing me this.
I will definitely try it out and get back to you within next week.
--
Rgds,
Subhadeep.
Please mark this post as a solution and also as helpful, if this resolves your issue or query.
Thanks,
Subhadeep Ghosh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2023 02:11 AM
Hi @subhadeep1618,
Scripts looks fine to me. Make sure that the query is correct and returns more than 1 records.
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar