1

can anyone please assist me on formulating a correct formula for to automatically generate a password based on this given formula : (Letter of First Name+ drop the zeroCIPSMemberNo+Firstletter of surname). I just dont know how to write the formula/apex code for this.

Please help!

Lucy

0

You can do something like this.

public String generatePassword() {

    String createPasswordFrom= 'AngryBirds'; // Generate the required string from which password should be generated. 
    String password = '';
    Integer len = 8; // password max len

    Integer count = createPasswordFrom.length();
    while (password.length() < len) {
        Double randomNo =  Math.random();
        integer IndexPosition = Math.mod(randomNo,count);
        password += createPasswordFrom.substring(IndexPosition, IndexPosition+1);
    }
    return password;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.