flow designer

HARSHA GOWDA R
Tera Contributor

Can i create 8 digit random password in flow designer?if yes how?



4 REPLIES 4

Deepak Shaerma
Kilo Sage

Hi @HARSHA GOWDA R 
Can you please explain the exact requirement?

Hi @Deepak Shaerma 
The scenario is after the approval from the manager for a password reset,the new random 8 digit password should be generated and it should trigger a notification in flow.

 

Vishwa Pandya19
Mega Sage

Hello Harsha,

 

You will have to create a custom action for this.

I have not defined any input but if required you can add on.
Please refer below screenshots.

VishwaPandya19_0-1713157851560.png

 

VishwaPandya19_1-1713157617695.pngVishwaPandya19_2-1713157629635.png


If my answer has helped you in any way please mark it as correct or helpful

Deepak Shaerma
Kilo Sage

Hi @HARSHA GOWDA R 
In your flow designer, after the managers approval trigger, add and action and Choose the Script Action to execute custom JavaScript code. 

(function() {
    // Function to generate a random 8-digit number as a string
    function generatePassword() {
        var min = 10000000; // Minimum 8-digit number
        var max = 99999999; // Maximum 8-digit number
        var password = Math.floor(Math.random() * (max - min + 1)) + min;
        return password.toString();
    }

    var newPassword = generatePassword();
    
    // Assuming ‘password_field’ is the field where the new password should be saved
    // And ‘current’ is the current record object in the Flow context
    current.password_field = newPassword;
    current.update(); // Don’t forget to update the record with the new password
    
    // Return the newPassword for further use in the Flow, like sending it in a notification
    return {
        newPassword: newPassword
    };
})();

Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma