Question on Schedule Job

Community Alums
Not applicable

Hi,

I have created a scheduled job and it worked well. Then I made it active as true. It is not working the opposite. Does it not work that way? The users active status stays active is false.

 

var gr = new GlideRecord("sys_user");
gr.addEncodedQuery("last_login<javascript&colon;gs.beginningOfLast6Months()");
gr.query();
while(gr.next()){
	gs.log("Scheduled job for last login information more than 180 days is executed");
	gr.setValue("active", false);
	gr.autoSysFields(false);
	gr.update();
}

 

Scheduled job_1.png

 

Scheduled job_2.png

 

Regards

Suman P.

1 ACCEPTED SOLUTION

Uncle Rob
Kilo Patron

I'd copy the query from that related list and paste it into the addQuery just to make absolutely 100% sure that I've selected the right records.  I'd even log out the User ID's to make sure the loop is hitting each of them.
Then you could do the update without hte setValue... just gr.active = true;
See if that makes a difference.

Also... did you actually execute it?  Because its scheduled to run only once for earlier this morning.
I'd test it on Demand until I got it right.

View solution in original post

1 REPLY 1

Uncle Rob
Kilo Patron

I'd copy the query from that related list and paste it into the addQuery just to make absolutely 100% sure that I've selected the right records.  I'd even log out the User ID's to make sure the loop is hitting each of them.
Then you could do the update without hte setValue... just gr.active = true;
See if that makes a difference.

Also... did you actually execute it?  Because its scheduled to run only once for earlier this morning.
I'd test it on Demand until I got it right.