06 October 2010

System Classes in Dynamics AX

RandomGenerate Class:

This class generates random numbers.
static void RandomGenerateEg(Args _args)
{
RandomGenerate objRG = new RandomGenerate();
Random objRandom = new Random();
;
//This generates random numbers specified within the given range
info(int2Str(objRG.randomInt(10,55)));

//This generates random numbers
info(int2Str(objRandom.nextInt()));
}
Executing this job generates random numbers. But it doesn’t guarantee that the numbers will not be repeated. So if the user needs unique number, he has to provide explicit check for that

Sequence Class:

Contrary to above class is Sequence class which generates the numbers in order.

static void SequenceEg(Args _args)
{
Sequence objSeq = new Sequence("Test Sequence",8,10,250,1);
print objSeq.currval(); // Displays the current value of the object
while(1)
{
print objSeq.nextval(10);
pause;
}
}
Sequence class takes the following parameters: SequenceName which can be a string of your choice, Identification No for the sequence, Initial Value, Maximum value
and a flag which indicates whether the cycle has to be repeated if maximum value is reached.

The method “nextVal” takes the value to be incremented for next number as parameter.

LastAOTSelection Class:

This class prints the last accessed AOT object by the user.

static void LastAOTSelectionEg(Args _args)
{
LastAOTSelection LS = new LastAOTSelection();
;
print LS.first().toString();
pause;
}

Keywords Class:

Class to list the available functions and keywords in Axapta.

static void KeywordsFunction(Args _args)
{
Keywords objKG = new Keywords();
str strOutput;
;
print Keywords::isValidIdentifier('dddd34'); // This method checks if the identifier is valid or nor
print Keywords::isValidIdentifier('*4532');
pause;

strOutput = objKG.firstFunction();
while(objKG.nextFunction()!= '')
{
strOutput = objKG.nextFunction();
info(stroutput);
}
}

static void KeywordsSymbol(Args _args)
{
Keywords objKG = new Keywords();
str strOutput;
;
strOutput = objKG.firstSymbol();
while (objKG.nextSymbol ()!='')
{
strOutput = objKG.nextSymbol();
info(stroutput);
}
}

No comments:

Post a Comment

Give me the commetns and solutions

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...