4. last login more than 6month user need to set inactive in servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 12:34 AM
set inactive

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 12:37 AM
You have multiple possibilities, but the easiest to create is a Daily Flow, which looks up the users who are eligible for inactivation, and sets all the fields needed.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 01:38 AM
Create a scheduled job to run daily:
var userGr = new GlideRecord('sys_user');
userGr.addEncodedQuery('last_login_time<javascript:gs.beginningOfLast6Months()');
userGr.query();
// Iterate through the result set
while (userGr.next()) {
userGR.active = false;
userGR.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 01:58 AM
1.You can use both scheduled job or flow designer to acieve your functionality .
2.As a best a best way you should use flow designer which will trigger on daily basis
3.You need to look up the user records who has not logged in since last 6 months ,update those user records as inactive
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact
Thanks,
Manjusha Bangale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 02:55 AM
Hello Keerthana,
You can create scheduled job by defining it to run daily or periodically
In script field we need to check for user who haven't logged in for more than 6 months
Script:
(function() {
var sixMonthsAgo = new GlideDateTime();
sixMonthsAgo.subtract(180); // subtracts 180 days i.e 6 months
var userGr = new GlideRecord('sys_user');
userGr.addQuery('last_login<', sixMonthsAgo);
userGr.query();
while(userGr.next()) {
userGr.active = false;
userGr.update();
}
})();
Save the scheduled job
If you want to add additional logic or notification when a user is marked inactive, you can create a business rule
set the table to sys_user and define condition and action you want to trigger when user's field active is set to false
Save the business rule
Activate the scheduled job