The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Populating a default password for users imported through excel file

Rain Vaine
Kilo Sage

Hello experts,

 

I have read in some documentations that we can use the run script option of the transform map to create or populate a field not included in the excel file. Is it also possible to the password field of the user table? If so, do you have idea on how to do it and the script to make it?

 

Thanks and Regards,

Vaine

1 ACCEPTED SOLUTION

@Rain Vaine try this

 

Setting the password field value through a transform row script is not recommended as the password field is encrypted and requires specific functions to set its value. Instead, it is recommended to use the default_password system property to set the default password value for new users.

Here's an example of how to set the default_password property:

  1. Navigate to System Properties > System.
  2. Search for the glide.security.default_password property.
  3. Set the value of this property to the desired default password.
  4. Save the property.

Now, whenever a new user is created, the default password will be set automatically.

Best practices for importing users from an Excel sheet include:

  1. Use a transform map to map the fields from the Excel sheet to the user table.
  2. Use the setPassword() function provided by the GlideRecord API to set the password value for each user.

Here's an example of a transform row script that imports users from an Excel sheet and sets their password:

(function transformRow(source, target, map, log, targetImportSetRow /*undefined on insert*/) {

  // Import fields from Excel sheet using source object
  target.setValue('first_name', source.first_name);
  target.setValue('last_name', source.last_name);
  target.setValue('email', source.email);

  // Set default password for new users
  var defaultPassword = gs.getProperty('glide.security.default_password');
  target.setPassword(defaultPassword);

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

 

View solution in original post

5 REPLIES 5

Hello,
Thanks for this another approach. I was able to make it work with transform functions script