How to set default password to a new users

Sathwik1
Tera Expert

How to set default password to a new user...when the user record inserted for the first time we need to set default password as "Sathwik@"

1 ACCEPTED SOLUTION

@Sathwik 

If you only want to set the default password for the users when you are loading in bulk then no need of Business rule.

you can handle this via onBefore transform script as well

Sample script below:

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

	// Add your code here

	target.user_password.setDisplayValue('Sathwik@');

})(source, map, log, target);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

26 REPLIES 26

Hi Sathwik - Create a before business rule with insert checkbox set to true with script as

current.user_password.setDisplayValue("test123");

Hi @Pradeep Sharma ,

 

Thanks it worked, but I had a small query..Now I have tested for single user...If I imported bulk user records then the same business rule will work?

@Sathwik 

If you want to update the default password for old users then try the script mentioned by @sachin.namjoshi 

For setting default password for any user when new user is created you can use before insert BR without script option as suggested by @Jaspal Singh 

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Sathwik  - Thanks for the update. Yes it will work as long as you have the run business rule checkbox set to true in the transform script.

P.S: When I tried the option without script i.e just using set field values it didn't work in my instance hence I have shared the script option.

Let me know if I have answered your question. If so, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

@Sathwik  - If the intent is to update the password only via import then you can switch the code to transform script i.e target.user_password.setDisplayValue('PASS PASSWORD HERE');. However if there is a use case where of records getting created manually then go with a business rule.