how to pass value from one activity to other activity in flow designer

Snow consultan1
Tera Contributor

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,

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi

  1. Create a system property called random.password.debug that's true/false
  2. Create a system property called random.password.length that's an integer of your password length
  3. Create a new action, call it "Generate random password"
  4. There are no inputs to this action
  5. Add a new step of the script type, call it Generate Random Password
    1. Set the required runtime to instance
    2. There are no input variables to this step
    3. Add a script (I've included the extract later, to keep this step-by-step easy to read)
    4. Create two output variables for this step
      1. One called generated_password that's of type "Password (2 Way Encrypted)" - this should be mandatory
      2. The other called generated_password_string that's of type "String" - this should be mandatory
  6. 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)
  7. Set the value of those outputs to
     find_real_file.png

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);

View solution in original post

9 REPLIES 9

Community Alums
Not applicable

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

Hi Mike,

 

could you please share me the script for Generate Random password activity and steps to configure activity?

Thanks

Community Alums
Not applicable

Hi

  1. Create a system property called random.password.debug that's true/false
  2. Create a system property called random.password.length that's an integer of your password length
  3. Create a new action, call it "Generate random password"
  4. There are no inputs to this action
  5. Add a new step of the script type, call it Generate Random Password
    1. Set the required runtime to instance
    2. There are no input variables to this step
    3. Add a script (I've included the extract later, to keep this step-by-step easy to read)
    4. Create two output variables for this step
      1. One called generated_password that's of type "Password (2 Way Encrypted)" - this should be mandatory
      2. The other called generated_password_string that's of type "String" - this should be mandatory
  6. 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)
  7. Set the value of those outputs to
     find_real_file.png

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);

looked for it. Your inputs helped me. Thanks

Prasant Kumar 1
Kilo Sage

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