Arpan Baishya
Kilo Sage

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. 

View solution in original post

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)?

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?

You may use the line below to order the NeedIt records in ascending order.

needit_gr.orderBy('sys_created_on');

 

Bert_c1
Kilo Patron

Set the scheduled job to run "on demand".