- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2024 10:26 PM
Hi @Piemur1,
You could try writing your script like this.
var needit_gr = new GlideRecord('insert_the_name_of_the_needit_table');
needit_gr.addNullQuery('u_requested_for_email');
needit_gr.setLimit(100);
needit_gr.query();
while(needit_gr.next()){
needit_gr.setValue('u_requested_for_email', needit_gr.u_requested_for.email);
needit_gr.update();
}
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 06:05 AM
Thank you. Is there a way to write the conditional on the Scheduled Script Execution so it only runs if there are any records where the Requested_for_Email is null? I would prefer that it not run unnecessarily if there are no records to even be run against. Is there a method of setting the Scheduled Script Execution to be inactive (Uncheck the active checkbox on the record itself)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 09:29 AM
It's running like a charm! Thank you! So now, is there a way to set an Order By to for example update the oldest Created dates first? Right now, there doesn't seem any rhyme or reason in which order these are being updated, but at the moment it does NOT appear to be updating by "Number" order or create date. Is there a preference for what order it does these updates, so long as they fulfill the .addNullQuery requirement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 11:05 AM
You may use the line below to order the NeedIt records in ascending order.
needit_gr.orderBy('sys_created_on');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 11:12 AM
Set the scheduled job to run "on demand".