- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 09:34 AM
I need to deactivate the users who have not logged it for the last 60 days. The system should check for it everyday at midnight and deactivate the users.
Solved! Go to Solution.
- Labels:
-
Request Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 09:43 AM
Hi,
You can create a scheduler with type script of your choosing and add below code.
var gr = new GlideRecord("sys_user");
var gdt = new GlideDateTime();
gdt.addDays(-60);
gr.addQuery("last_login_time","<=",gdt);
gr.addActiveQuery();
gr.query();
gr.active=false;
gr.updateMultiple();
Mark the comment as a correct answer and helpful if it helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 09:38 AM
Configure flow designer flows and you can schedule this flow every night to make user inactive if they don't logged in from last 60 days.
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 09:43 AM
Hi,
You can create a scheduler with type script of your choosing and add below code.
var gr = new GlideRecord("sys_user");
var gdt = new GlideDateTime();
gdt.addDays(-60);
gr.addQuery("last_login_time","<=",gdt);
gr.addActiveQuery();
gr.query();
gr.active=false;
gr.updateMultiple();
Mark the comment as a correct answer and helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2021 06:43 PM
Hi,
This script was useful and works. can you please provide the roll back script aswell.
Thanks.