- 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-28-2020 02:25 PM
We have achieved this use case by creating an action to generate a random password. YOu can then use the output of that action on as many steps as you need to in the flow.
(So you can use it in both the AD orchestration, as well as pass it into an outbound notification)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2020 06:44 PM
HI
Thanks for the reply. we are trying exactly the same but missing something. can you please help us how to capture the output of previous activity and reuse( as like scratch pad in normal workflow)?
Thanks in advance
Best Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2020 03:13 AM
Hi
So we have built an action called "Generate Random Password" where we pass in a number of characters as an input. We then have a script step to actually generate the password and the output of the step is the string you want to use as your password.
Then when you build a flow, you can use this string as a data pill whenever you like
So in this example, we're passing this into the AD spoke to use to reset the password, we then use the same 2==>Random Password pill later on in the notification step
(note that 6.2==>Password is the same string as the 2==>Random Password step, it's just because of how complex this flow is, it's split into multiple sub flows that we pass values between :-))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2020 07:14 PM
Hi
Thank you for detailed explanation. This certainly helps us.
Can you please clarify below queries?
in your random password generation, there are 2 outputs. 1. Random password and 2. Random password string?
what is the difference? are they both store same value?
in your reset AD password, you are using random password output. that means was it already encrypted as AD requires double encrypted password?
Thanks in advance?