How to pass the parameter from one form to another in Dynamic365

1. Create two forms with Name FormA & FormB  
2. Below code is override in clicked method() of button.
void clicked()
{
    // Args class is usually used in Axapta for passing parameters between forms
    Args            args;
    FormRun         formRun;
    ;
    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 like
    args.parm(  LeaveRequestID.text() );
    // If we want pass whole record we can use 'parm' method of 'Args' class   
    args.record(TableName);
    // Run FormB
    args.name( formstr( FormB ) );
    formRun = classFactory.formRunClass( Args );
    formRun.init();
    formrun.run();
    formrun.wait();
    super();
}

3. Now override init() method in FormB.

public void init()
{
    str           anyStringValueFromCaller;
    TableName     tablename;
    ;
    super();
    // Check for passed arguments
    ifelement.args())
    {
        // get string parameter
        anyStringValueFromCaller = element.args().parm();                                                  
        SelectedLeaveRequestID.text(anyStringValueFromCaller);
        // get record
        tablename = element.args().record();
    }
}

Comments

Popular posts from this blog

SSRS Report using Controller , Contract and RDP classes in D365

Exporting data to Excel through X++ code

COC for Form level method

Multi Select Lookup in SSRS Report in D365