- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Saturday
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sunday
Hi @scottbjorke ,
in your script
is a GlideList field, not a simple string. you’re actually storing a reference to the GlideElement, not the actual list of sys_ids.
and
this doesn’t set the field correctly, so the second .update() doesn’t persist the change..
address_list works fine because it’s just a string, but user_list needs proper handling
so you can use the toString(),Save the original user_list as a string of sys_id:
var orig_user_list = grScheduledReport.user_list.toString();
var orig_address_list = grScheduledReport.address_list.toString();
and the set the values
grScheduledReport.user_list = orig_user_list;
grScheduledReport.address_list = orig_address_list;
grScheduledReport.update();
Always use .toString() to save and restore GlideList fields. Directly assigning the GlideElement won’t work, which is why your second .update() appeared to fail.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sunday
Hi ,
SncTriggerSynchronizer.executeNow(grScheduledReport) runs asynchronously and re-saves the same sysauto_report record after your second update()
Add this gs.sleep and then update
gs.sleep(30000); // wait 30 seconds
grScheduledReport.address_list = orig_address_list;
grScheduledReport.user_list = orig_user_list;
grScheduledReport.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sunday
You need to get the value of the original fields using the safer and recommended getValue, or you can force them to a string when assigning to script variables:
var orig_user_list = grScheduledReport.getValue('user_list'); // GlideList
var orig_address_list = grScheduledReport.getValue('address_list'); // comma-separated list of email addresses
- or -
var orig_user_list = grScheduledReport.user_list.toString(); // GlideList
var orig_address_list = grScheduledReport.address_list.toString(); // comma-separated list of email addresses
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sunday
Hi @scottbjorke ,
in your script
is a GlideList field, not a simple string. you’re actually storing a reference to the GlideElement, not the actual list of sys_ids.
and
this doesn’t set the field correctly, so the second .update() doesn’t persist the change..
address_list works fine because it’s just a string, but user_list needs proper handling
so you can use the toString(),Save the original user_list as a string of sys_id:
var orig_user_list = grScheduledReport.user_list.toString();
var orig_address_list = grScheduledReport.address_list.toString();
and the set the values
grScheduledReport.user_list = orig_user_list;
grScheduledReport.address_list = orig_address_list;
grScheduledReport.update();
Always use .toString() to save and restore GlideList fields. Directly assigning the GlideElement won’t work, which is why your second .update() appeared to fail.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Why post the same answer 4 hours later, without adding any value, and excluding the ServiceNow recommended approach of always using 'getters and setters' getValue and SetValue to ensure proper field value retrieval and assignment?
