- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2023 06:09 AM
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: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();
}
Regards
Suman P.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2023 06:26 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2023 06:26 AM
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.