scheduled job to make active field false by comparing dates

Asif_Jawed
Tera Expert

I need to create a schedule job for custom table which will run every day. The Schedule job will compare current datetime field with custom date field and if that date matches, make active false. I have written the code below. It is not working.

 

AsifJawed1_0-1696843206669.png

 

6 REPLIES 6

Anand Kumar P
Giga Patron
Giga Patron

Hi @Asif_Jawed ,

As scheduled job is server side script g_form will not work so write 

gr.setValue('active', false);

Please mark it as solution proposed and helpful if it works.

Thanks,

Anand

Sandeep Rajput
Tera Patron
Tera Patron

@Asif_Jawed Please update your scheduled job script as follows.

 

var gr = new GlideRecord('u_candidate_profile’);
gr.addEncodedQuery (“numberISNOTEMPTY^u_current_dateISNOTEMPTY");
gr.query();
while(gr.next()){
var dateTimeStr = gr.getDisplayValue(‘u_current_date");
var dateArr = dateTimeStr.split(" ");
var currentdate = dateArr[0];

var pooldate = gr.getDispleyValue(‘u_talent_pool_expiry date’);
if(date == pooldate){

gs.addInfoMessage("code testing code testing");
gr.setValue( ‘active’, false);
gr.update();
}



Hope this helps.

Alex Tod1
Kilo Sage

Hello @Asif_Jawed

  I notice that in line 14 I use "g_form", this is a specific client side function, I think you have to correct with your "gr" object, more precisely "gr.setValue()".  In the if condition, who is data variable? I notice that it is not declared.

  

Asif_Jawed
Tera Expert

made all the changes but still not working

AsifJawed1_0-1696859595777.png