import user data with password generated by script?

Pavan Nagidi
Tera Expert

Hello Experts,

I am trying to import user data using import sets from xls file.   I am using a script in the transform map variable mapping to generate password but that's not working. Could you please suggest, where I am doing wrong?

Script

var FN = source.u_first_name.toString();

var LN = source.u_last_name.toString();

var firstLength=FN.length;

var secondLength=LN.length;

target.user_password=FN.charAt(0).toUpperCase()+firstLength+FN.charAt(firstLength-1)+LN.charAt(0).toUpperCase()+secondLength+LN.charAt(secondLength-1);

Also attaching transform map screen shots FYR.

Thanks

Pavan

1 ACCEPTED SOLUTION

Guys,



The below script works for setting password using script while importing user profiles from import sets.



var FN = source.u_first_name.toString();


var LN = source.u_last_name.toString();


var firstLength=FN.length;


var secondLength=LN.length;


var pwd=FN.charAt(0).toUpperCase()+firstLength+FN.charAt(firstLength-1).toLowerCase()+LN.charAt(0).toUpperCase()+secondLength+LN.charAt(secondLength-1).toLowerCase();


answer=pwd;


Not sure why they are using answer!!! Below link will helpful.


http://www.snc-blog.com/2013/11/05/importing-users-with-password/


View solution in original post

6 REPLIES 6

amaradiswamy
Kilo Sage

Hi Nagidi,



What you are doing is correct and will import the data as per the script. As password field is an encrypted data type, it will appear as empty, but the data will be stored.



If you want to test, you can logout and try to login by using your logic for password.



Thanks and regards,


Swamy


Hi Swamy,



Tried the same, but thats not working.



Thanks


Pavan


tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Pavan,


When you say "I am using a script in the transform map variable mapping to generate password but that's not working."


What symptoms do you see that lets you know it is not working?



I would suggest that you test by importing just for one user, and initially try with a a fixed string, say "MyPassword275232" assigned to target.user_password.


once you can log in with "MyPassword275232", you could then move on to auto generate passwords, for one user.



Actually first step might be to check for the specific user you can log in with a manually, from the GUI, assigned password.


There are a few possible causes of that not working, user locked out, user not active, authentication taking place via LDAP, which could be eliminated by a quick test.



Best Regards



Tony



Thank you Tony, for getting back to me.



Will try that out and keep you posted.



Thanks


Pavan