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

SysOperation framework: Pass selected records from a temporary table

In the following scenario, all records of a temporary table are to be passed to a SysOperation construct.

For that we need:

  • In the DataContract, a accessor method (parm-method) that takes a container
  • In the controller, a logic that iterates the records of a calling data source and packs it into a container, and passes it to the service using the above method
  • In the service class we need code, which unpacks and processed the transferred container



class TutorialSysOperationController extends SysOperationServiceController

In the new()-method, we link the controller to the service class.

void new()

    this.parmMethodName(methodStr(TutorialSysOperationService, runService));

The main()-method is the classic entry point when the controller is called via a MenuItem. Here, the calling data source is passed to the service class using the DataContract.

public static void main(Args _args)
    TutorialSysOperationController controller;
    SysOperationStartResult sysOperationStartResult;
    TutorialSysOperationDataContract dataContract;
    Set recordSet;
    TmpInventTable tmpInventTable;
    MultiSelectionHelper multiselectionHelper;

    controller = new TutorialSysOperationController();


    // Get marked records from calling form
    if (_args && _args.caller() is FormRun)
        recordSet = new Set(Types::Record);
        multiselectionHelper = MultiSelectionHelper::createFromCaller(_args.caller());   
        tmpInventTable = multiselectionHelper.getFirst();
        while (tmpInventTable)
            tmpInventTable = multiselectionHelper.getNext();

    // Put records from calling datasource into dataContract
    dataContract = controller.getDataContractObject();
    if (dataContract is TutorialSysOperationDataContract)

    sysOperationStartResult =



public class TutorialSysOperationDataContract
    container recordCon;


[DataMemberAttribute, SysOperationControlVisibilityAttribute(false)]
public container parmRecordCon(container _recordCon = recordCon)
    recordCon = _recordCon;

    return recordCon;



class TutorialSysOperationService extends SysOperationServiceBase

The method runService() is the actual service method. By means of the attribute SysEntryPointAttribute we control here that no further authorization checks are necessary.

public void runService(TutorialSysOperationDataContract _dataContract)
    Set recordSet;
    SetEnumerator se;
    Common record;
    TmpInventTable tmpInventTable;

    // Process records
    if (conLen(_dataContract.parmRecordCon()) > 0)
        recordSet = Set::create(_dataContract.parmRecordCon());
        se = recordSet.getEnumerator();
        while (se.moveNext())
            record = se.current();

            switch (record.TableId)
                case tableNum(TmpInventTable):   
                    tmpInventTable = record;
                    info(strFmt("%1 %2", tmpInventTable.ItemId, tmpInventTable.ItemName));
                    info(strFmt("%1", record.RecId));
These post applies to following version:
Dynamics AX 2012

Srikanth Konda 11/17/2021 05:37 | #1

Very useful post, thanks a lot

Add comment


Posts of the actual month
Februar 2024
© 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.