- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 03:24 AM
How can I automatically set a password for Contact X when a user with role: sn_customerservice.customer_admin self-created Contact X using the item "Create Contact"?
I have successfully set up user ID automatically in FlowDesigner, but I cannot set up a password.
We would like to complete the creation of contacts only by the customer, without the system administrator (admin, etc.) intervening in the creation of contacts.
I would appreciate if someone could give me some advice.
Thanks,
Haruka Kubota
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2022 03:44 AM
Hi
Sure, will assist you here.
Password field which we are trying to set here is a field of dictionary type = password which once set cannot be decrypted and you cannot see the value once it is set.
So please do not get confused with SetDisplayValue being used, it will not show. IF that is giving you an error then please modify your script as below:
(function executeRule(current, previous /*null when async*/ ) {
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
var string_length = 8;
var randomstring = '';
for (var i = 0; i < string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum, rnum + 1);
}
//Generate Notification
gs.eventQueue("user.password", current, randomstring, current.email);
//Set values in User record
current.user_password = randomstring;
current.password_needs_reset = true;
current.update();
})(current, previous);
This Script should work fine now without any issues for you.
Second query:
In the script above, if you see there is a line written with syntax as below:
gs.eventQueue("user.password", current, randomstring, current.email);
So user.password is a Event which you need to configure first, please follow the steps through which you can configure this:
1) Navigate to the module "Registry" and create a event named "user.password" as shown below:
Now if you need to send this password to someone then we are passing the password as one of the event parameter, so you can access that in a Notification email script which can then be used in a Notification as per steps below:
Navigate to the module "Notification Email Script" and use the script as below which will allow you to send the password generated to the email which is also a parameter being passed from your Business Rule above:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
var par1 = event.parm1.toString();
template.print('Password is ' + par1);
})(current, template, email, email_action, event);
Final Step:
Configure your Notification:
Notification should be on the same table as your Business Rule
Trigger Condition will be Event Based and select the event name configured in steps above.
Make sure to select below 3 parameter:
Parm 1
Parm 2
Send to Event Creator
You can call the Notification email script in your Notification using the syntax below:
${mail_script:Mail Script Name}
Adding the screenshot as well for your reference on how you are going to create your Notification as well to avoid any confusion:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 01:29 AM
Thank you very much for your kindness.
I was able to solve the problem using the method you taught me. It helped me a lot!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2024 12:19 PM
is this still valid using the customer contact table? I was getting some duplicate entry errors.