scheduled job to make active field false by comparing dates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 02:20 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 04:03 AM - edited 10-09-2023 05:51 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 04:54 AM
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 05:13 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 06:53 AM
made all the changes but still not working