Monday, December 24, 2018

Update multiple record through MultiSelectionHelper class in AX 2012

Main method of class:
public static void main(Args args)
{
    FormDataSource                      formDataSource;
    TableName                           tableName;
    FormRun                             caller = args.caller();
    MultiSelectionHelper                helper = MultiSelectionHelper::createFromCaller(caller);
;
    // Find correct form data source
    for (i = 1; i <= caller.dataSourceCount(); i++)
    {
        formDataSource = caller.dataSource(i);
        if (formDataSource.table() == tableNum(TableName))
        {
            break;
        }
    }
    //Create ranges for the selected records
    helper.createQueryRanges(formDataSource.queryBuildDataSource(), fieldStr(TableName, RecId));
    // Traverse the selected records
    tableName = helper.getFirst();
    ttsBegin;
   
    while(tableName)
    {
        // Logic placeholder-Start
       
        // Logic placeholder-End
        tableName = helper.getNext();    
    }
    ttsCommit;
}

No comments:

Post a Comment