Sunday, November 23, 2014

Random password both Number and String in ax 2012

// Random password

static void RandomNumberString(Args _args)
{
    //RandomGenerate RandomRange = new RandomGenerate();
    //Random Random = new Random();
    //;
    //info(int2Str(RandomRange.randomInt(20,100)));
    //info(int2Str(Random.nextInt()));

    int i;
    RandomGenerate random = new RandomGenerate();
    str password;
    int passwordLength = 8
    ;
    for (i=1; i<= max(2, passwordLength); i++)
    {
        if (i mod 2)
            password += num2char(random.randomInt(char2num('a', 1), char2num('z', 1)));
        else
            password += num2char(random.randomInt(char2num('0', 1), char2num('9', 1)));
    }
    info(password);
}

No comments:

Post a Comment

Disabling the flight in D365FO (CHD - Tier 1)

 INSERT INTO dbo.SYSFLIGHTING(FLIGHTNAME, ENABLED)  VALUES ('<FlightObjectName>_KillSwitch', 1)  or  INSERT INTO dbo.SYSFLIGHT...