Tuesday, 15 October 2013

Passing the container value between the forms in Dynamic AX

X++ job using container


static void Intro_For(Args _args)
{
Container names = ["Lay", "Kai", "Zbigniew", "Rolf", "Memed"];
Counter counter;
;
for (counter=1; counter <= conlen(names); counter++)
{
info(strFmt("%1: Name: %2", counter, conpeek(names, counter)));
}
}

 

Passing the container value between the forms in Dynamic AX

Over ride as init() method in FormB
public void init()
{
    str             anyStringValueFromCaller;
    container       contain;
    ;
    super();
    // Check for passed arguments
    if( element.args() )
    {
        // get string parameter
        //anyStringValueFromCaller =
        contain = str2con(element.args().parm());
        Sex.text(conPeek(contain,1));
        MaritalStatus.text(conPeek(contain,2));       
        anyStringValueFromCaller = conPeek(contain,3);
        AccountNum.text(anyStringValueFromCaller);
    }
}
Override as clicked() in FormA
void clicked()
{
    // Args class is usually used in Axapta for passing parameters between forms
    Args            args;
    FormRun         formRun;
    container contain;
    str        containstr;
    ;
    args = new args();
    // Our values which we want to pass to FormB
    // If we want pass just simple string we can use 'parm' method of 'Args' class
   contain = [sex.valueStr(),MaritalStatus.valueStr(),AccountNum.valueStr()];
    containstr = con2Str(contain);
    args.parm(containstr);
    // Run FormB
    args.name(formstr(DBForm));
    formRun = classFactory.formRunClass(Args);
    formRun.init();
    formrun.run();
    formrun.wait();
    super();
}

No comments:

Post a Comment