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

A default password could represent a security risk.

But, you can always have a process on which a temporary new password is set to the new users. I will imagine this can either be done through script or through the action of a support agent and/or admin in the instance.

 

Users are pulled from LDAP, AD integration.

Do you have AD integration to pull users records?

 

Regards,

Sachin

Yes, It will fixed by script...I tried using business rule but not worked for me...can you suggest how to proceed?

Use below script to update default password for users.

You need to update query for returning correct user records.

 

 var usr = new GlideRecord('sys_user');


          usr.addQuery('active', 'true');


          usr.addQuery('user_name', userid);


          usr.query();

while(usr.next()){


                      var newpw = "test124";


                      usr.user_password.setDisplayValue(newpw);


                      usr.password_needs_reset = true;


                      usr.update();

}

 

 

Thanks for your reply,

If I written above script it will update for all records..but what my requirement is whenever the new user record was created then only we need to set default password.

Use this script in business rule advance section on sys_user table.

 

Regards,

Sachin