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

1 Answer 1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .