- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 05:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-25-2016 08:29 PM
Sunny,
var gr = new GlideRecord('sys_user');
//The below query will reset the password for all users whose date of password is dated more than 20 days before.Change accordingly.
gr.addQuery('u_date_of_password','<','gs.daysAgo(-20))');
gr.query();
while (gr.next())
{
gr.password_needs_reset = true;
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 08:46 PM
Hi Sunny,
Here is how you can :
1. Goto System Definitions > Scheduled jobs
Select Automatically run a script of your choice.
2. In the run field select monthly and write the below script :
var gr = new GlideRecord('sys_user');
//The below query will reset the password for all users. You can add query as per your need here.
gr.query();
while (gr.next())
{
gr.password_needs_reset = true;
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 08:48 PM
I thought about that at first also, but it resets everyone regardless, even if they just reset their own password yesterday. You need to keep track of the last time it was reset and only affect those people after 30 days.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 08:55 PM
Chuck,
Oh yes. I did not think of that scenario before. And yes the script-less scheduled job is really helpful when you are new to ServiceNow, this handles the scripted jobs like a charm. Thanks a lot for sharing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 10:12 PM
Hi Harneet
As check mentioned I created datetime field on the user form and everytime the password changes, it will set the date time field to current value. For this all I created a business rule, but this business rule is not filling the datetime field with current value. Below is my business rule
(function executeRule(current, previous /*null when async*/) {
ccur=current.getValue('user_password');
cprev=previous.getValue('user_password');
if (ccur!=cprev)
{
current.setValue('u_date_of_password',gs.nowDateTime());
gs.addInfoMessage('hello');
}
})(current, previous);