- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2020 10:02 AM
Hi All,
we are trying to integrate AD using AD spoke in integration hub. we have a requirement to generate random password and send it to user. here we are using flow designer.
how can we send an email with password, which is generated in one of the activity in flow designer?
is there a way that we can encrypt and send it to user (confidentiality)?
Thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2020 02:41 AM
Hi
- Create a system property called random.password.debug that's true/false
- Create a system property called random.password.length that's an integer of your password length
- Create a new action, call it "Generate random password"
- There are no inputs to this action
- Add a new step of the script type, call it Generate Random Password
- Set the required runtime to instance
- There are no input variables to this step
- Add a script (I've included the extract later, to keep this step-by-step easy to read)
- Create two output variables for this step
- One called generated_password that's of type "Password (2 Way Encrypted)" - this should be mandatory
- The other called generated_password_string that's of type "String" - this should be mandatory
- Add two outputs, one called randompassword (Type Password 2 way encrypted) and the other called randompasswordstring (type String) (You can make the labels of these nicer)
- Set the value of those outputs to
Now you have an action that you can reuse. The script extract for the step is below.
(function execute(inputs, outputs) {
try {
// Variables
var debugOn = gs.getProperty('random.password.debug');
var passwordLength = gs.getProperty('random.password.length');
var upperCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var lowerCharacters = "abcdefghijklmnopqrstuvwxyz";
var numbers = "123456789";
var regex = new RegExp("(?=.*[A-Z])(?=.*[2-9])(?=.*[a-z])");
var randomPassword = "";
var amountOfVariables = 3; // How many variables are used in the password
var isValidPassword = false;
// Functions
function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
function generateRandomPassword() {
while (isValidPassword == false) {
// reset password if invalid
randomPassword = "";
while (randomPassword.length != passwordLength) {
switch(getRandomInt(amountOfVariables)) {
case 0:
randomPassword += upperCharacters.charAt(Math.floor(Math.random() * upperCharacters.length));
break;
case 1:
randomPassword += lowerCharacters.charAt(Math.floor(Math.random() * lowerCharacters.length));
break;
case 2:
randomPassword += numbers.charAt(Math.floor(Math.random() * numbers.length));
break;
}
}
if(regex.test(randomPassword)) {
isValidPassword = true;
}
}
return randomPassword;
}
// Debug
if(debugOn == 'true') {
gs.log("Random password action start");
gs.log("Password length property is: " + passwordLength);
gs.log("Random Password is: " + randomPassword);
gs.log("Valid Password: " + isValidPassword);
}
var password = generateRandomPassword()
// Output password
outputs.generated_password = password;
outputs.generated_password_string = password;
}
catch(error) {
gs.log("Error!: " + error);
}
})(inputs, outputs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2020 03:24 AM
Hi
It contains the same value, but one held as a string (that we can use in notifications), and one held as a 2 way encrypted password that can be used with the IntegrationHub AD spoke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2020 12:53 AM
Hi Mike,
could you please share me the script for Generate Random password activity and steps to configure activity?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2020 02:41 AM
Hi
- Create a system property called random.password.debug that's true/false
- Create a system property called random.password.length that's an integer of your password length
- Create a new action, call it "Generate random password"
- There are no inputs to this action
- Add a new step of the script type, call it Generate Random Password
- Set the required runtime to instance
- There are no input variables to this step
- Add a script (I've included the extract later, to keep this step-by-step easy to read)
- Create two output variables for this step
- One called generated_password that's of type "Password (2 Way Encrypted)" - this should be mandatory
- The other called generated_password_string that's of type "String" - this should be mandatory
- Add two outputs, one called randompassword (Type Password 2 way encrypted) and the other called randompasswordstring (type String) (You can make the labels of these nicer)
- Set the value of those outputs to
Now you have an action that you can reuse. The script extract for the step is below.
(function execute(inputs, outputs) {
try {
// Variables
var debugOn = gs.getProperty('random.password.debug');
var passwordLength = gs.getProperty('random.password.length');
var upperCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var lowerCharacters = "abcdefghijklmnopqrstuvwxyz";
var numbers = "123456789";
var regex = new RegExp("(?=.*[A-Z])(?=.*[2-9])(?=.*[a-z])");
var randomPassword = "";
var amountOfVariables = 3; // How many variables are used in the password
var isValidPassword = false;
// Functions
function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
function generateRandomPassword() {
while (isValidPassword == false) {
// reset password if invalid
randomPassword = "";
while (randomPassword.length != passwordLength) {
switch(getRandomInt(amountOfVariables)) {
case 0:
randomPassword += upperCharacters.charAt(Math.floor(Math.random() * upperCharacters.length));
break;
case 1:
randomPassword += lowerCharacters.charAt(Math.floor(Math.random() * lowerCharacters.length));
break;
case 2:
randomPassword += numbers.charAt(Math.floor(Math.random() * numbers.length));
break;
}
}
if(regex.test(randomPassword)) {
isValidPassword = true;
}
}
return randomPassword;
}
// Debug
if(debugOn == 'true') {
gs.log("Random password action start");
gs.log("Password length property is: " + passwordLength);
gs.log("Random Password is: " + randomPassword);
gs.log("Valid Password: " + isValidPassword);
}
var password = generateRandomPassword()
// Output password
outputs.generated_password = password;
outputs.generated_password_string = password;
}
catch(error) {
gs.log("Error!: " + error);
}
})(inputs, outputs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2021 03:38 PM
looked for it. Your inputs helped me. Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2020 07:57 PM
Hi,
Basically we use Data panel and data pill picker for passing values from one activity to another in Flow designer.
If I was able to solve your Query, please mark my answer correct and helpful.
Thanks & Regards
Prasant Kumar Sahu