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.

User creation via script and sharing credentials

sunilsargam
Kilo Sage

hello Team,

 

I’ve created a custom table that extends the sys_user table. A user record is being generated under certain conditions via a Business Rule.

 

Once the user is created, I set a password programmatically and send the login credentials to the user via email.

 

While the password appears to be set successfully, when the user tries to log in through the ESC portal using the provided credentials, they receive an "Invalid credentials" error.

 

Has anyone encountered a similar issue or can offer guidance on this?

Thank you!

9 REPLIES 9

GlideFather
Tera Patron

Hi @sunilsargam 

are they using the correct user name?

Have you tried it for you as well?

_____
No AI was used in the writing of this post. Pure #GlideFather only

@sunilsargam let's assume that the password is inserted correctly, the other and only possibility would be the username, which is the User ID (user_name) and this must be strictly unique.

admin in the case below:

KamilT_0-1753282197064.png

 

_____
No AI was used in the writing of this post. Pure #GlideFather only

Hello @GlideFather ,

 

im writing the below script and in xml i can see this value is populated. but when im trying to login, it is giving me error. 

    var gr = new GlideRecord("customTable");
    gr.get(userSysId);
    var pass = "test";
    gr.user_password = pass; // Set the password field directly
    gr.update();

I guess that the password is evaluated against this value:

Screenshot 2025-07-23 at 15.56.01.png

 

So you nee d to create a user account with the user_password value and that allows them to enter.

 

You can try it first manually:

  •  create a user with user_name "test.password",
  • user_password set to any value you will remember,
  • good practice is to set "password needs reset" to true.

 

Then go to incognito or another browser use the /login.do and try it 

when this passes OK you will need to adjust your script to insert the User to the User table

_____
No AI was used in the writing of this post. Pure #GlideFather only