This post is machine-translated. The original post in german language can be found here.

SysOperation: Open form with specific record after processing

Imagine the following scenario: You have to create or update a record using a clas, which extends Sysoperation-Framework. After this database operation you have to open a particular form, which allows the user to modify the just created/modified record.

For such tasks i like to use the aferoperation()-method from the Controller-Class. By using the operationReturnvalue of the Service-Class within this method it is possible to process the record.

Example:

protected void afterOperation(SysOperationExecutionMode _executionMode, AifAsyncResult _asyncResult)
{
    CustTable createdCustTable;
    SysInfoAction_Formrun sysInfoAction;
    
    void openFormThroughCode(CustTable _ct)
    {
        FormRun formRun;
        args localArgs = new args();

        localArgs.name(formstr(CustTable));

        localArgs.formViewOption(FormViewOption::Grid);
    
        localArgs.record(_ct);
    
        formRun = classFactory.formRunClass(localArgs);
        formRun.run();

        formRun.wait();
    }

    super(_executionMode, _asyncResult);

    if(this.getServiceClass().id() == classNum(TutorialSysOperationService))
    {
        createdCustTable = this.operationReturnValue();    // TutorialSysOperationService.runService() returns CustTable record
    }

    if( !isRunningOnServer())
    {
        openFormThroughCode(createdCustTable);   
    }
    else
    {
        sysInfoAction = SysInfoAction_FormRun::newFormname(formStr(SalesTable));
        sysInfoAction.parmCallerBuffer(createdCustTable);

        info(strFmt("Click here to open customer form"), "", sysInfoAction);
    }
}
These post applies to following version:
Dynamics AX 2012

Ramya Gaddam 11/07/2017 11:25 | #1

Good Post:)
Suppose if I want to open form with multiple records of some criteria then how to achieve this when running on server?

Add comment
 
 

 

 
 
 
Posts of the actual month
März 2024
MoTuWeThFrSaSu
 123
45678910
11121314151617
18192021222324
25262728293031
 
© 2006-2024 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.