Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Set selected users "Password needs reset" to True

soelofsen
Kilo Explorer

HI,

I would like to find out the simplest way of reseting the flag "Password needs reset" in the user record to true. Ideally, i would like to do this to a selected group, with the relevant members associated to that group, or all users with the ITIL role.

Would a UI action work for this? if so, how and what would the script look like, as i currently have
current.password_needs_reset = 1; and also tried
current.password_needs_reset = true; on the User table.

Any suggestions?

Thanks
Shaun

3 REPLIES 3

Mark Stanger
Giga Sage

You need to put the value in quotes when setting a boolean field. You also need to make sure to call the update on the record.



current.password_needs_reset = '1';
current.update();


...or...



current.password_needs_reset = 'true';
current.update();


If you want to click an option on a group record and apply the change to all members of that group you could use the following script in a 'List Choice' UI Action on the Group Member ('sys_user_grmember') table. That way, you could select the users from the related list on the group form and apply the action.



//Query the user record...
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', current.user.sys_id);
gr.query();

//Update the user record if found...
if(gr.next()){
gr.password_needs_reset = 'true';
gr.update();
}



HI Mark,

Thanks very much for this..

I realised that i left the current.update(); out of the script earlier, and ran the script, and it worked, but the script for the group membership stuff is great..

Thanks very much 🙂
SHaun


Hello Folks

I was looking at this post and wondering how to use it to set the password_needs_reset parameter to true when a new user is created during an automatic LDAP import. At the moment, users are created with a blank password and I want to enhance security a bit.

Additionally, I would also check for empty passwords and force users to create one.

Thanks for your help,

Christian