D365/AX7: Multi Select LookUp In Form Grid (SysLookupMultiSelectGrid)

Requirement

Multi Select Lookup Of Warehouse In Form Grid.

Untitled

Sample Code

  1. Create a new Class AcxSysLookupMultiSelectGrid & extend it from SysLookupMultiSelectGrid.class AcxSysLookupMultiSelectGrid extends SysLookupMultiSelectGrid
    {
    #Characters
    public void setSelected()
    {
    dictfield dictField;
    Common currentDSRecord;
    FormDataSource formdatasource;
    callingControlId.text(SysOperationHelper::convertMultiSelectedValueString(selectedId));
    formdatasource = callingControlId.dataSourceObject();
    if(formdatasource && callingControlStr.dataField())
    {
    dictfield = new dictfield(formdatasource.table(),callingControlStr.dataField());
    currentDSRecord = formdatasource.cursor();
    currentDSRecord.(dictfield.id()) = currentDSRecord.(dictfield.id()) + SysOperationHelper::convertMultiSelectedValueString(selectedStr);
    callingControlStr.update();
    }
    else
    {
    callingControlStr.text(SysOperationHelper::convertMultiSelectedValueString(selectedStr));
    }
    }

    public static AcxSysLookupMultiSelectGrid construct(FormControl _ctrlId,
    FormControl _ctrlStr)
    {
    AcxSysLookupMultiSelectGrid lookupMS;
    lookupMS = new AcxSysLookupMultiSelectGrid ();
    lookupMS.parmCallingControlId(_ctrlId);
    lookupMS.parmCallingControlStr(_ctrlStr);
    return lookupMS;
    }

    }

  2. Override the Lookup() method of form control.
    public void lookup() {
    AcxUserSetup.InventlocationMulti = ”;
    multiSelectGrid = AcxSysLookupMultiSelectGrid ::construct(AcxUserSetup_InventlocationMulti,AcxUserSetup_InventlocationMulti);
    Query query = new Query();
    QueryBuildDataSource queryBuildDataSource;
    queryBuildDataSource = query.addDataSource(tableNum(InventLocation));
    queryBuildDataSource.addSelectionField(fieldNum(InventLocation, InventLocationId));
    queryBuildDataSource.addSelectionField(fieldNum(InventLocation, Name));
    multiSelectGrid.parmQuery(query);
    multiSelectGrid.parmCallingControl(this);
    multiSelectGrid.run();

    //super();
    }

 

Leave a Reply