Multi-select parameters in dialogs

Example of RunBaseBatch based job with multi-select parameter (wharehouses)
class MultiSelectRunBaseBatch extends RunBaseBatch
    container                   warehouses;
    SysLookupMultiSelectCtrl    warehouseMultiSelect;
    FormBuildStringControl      warehouseCtrl;
    DialogField                 warehousesField;


protected Object dialog()
    DialogRunbase       dialog;
    DialogGroup         dialogGroup;
    FormBuildControl    formBuildControl;

    dialog = super();


    dialogGroup         = dialog.addGroup();
    formBuildControl    = dialog.formBuildDesign().control(dialogGroup.formBuildGroup().id());
    warehouseCtrl       = formBuildControl.addControl(FormControlType::String, identifierstr(InventLocationId));

    return dialog;

public void dialogPostRun(DialogRunbase dialog)
    FormRun                 formRun;
    FormStringControl       fsCtrlWarehouse;
    Query                   q;
    QueryBuildDataSource    qbds;

    q       = new Query();
    qbds    = q.addDataSource(tablenum(InventLocation));

    qbds.addSelectionField(fieldNum(InventLocation, InventLocationId));
    qbds.addSelectionField(fieldNum(InventLocation, Name));


    formRun = dialog.dialogForm().formRun();

    if (formRun)
        fsCtrlWarehouse =;
        warehouseMultiSelect = SysLookupMultiSelectCtrl::constructWithQuery(formRun, fsCtrlWarehouse, q);
        warehouseMultiSelect.set([this.warehouseIdsToRecIds(warehouses), warehouses]);

public boolean getFromDialog()

    boolean ret;

    ret             = super();
    warehouses      = this.warehouseRecIdsToIDs(warehouseMultiSelect.get());

    return ret;

public container pack()
    return [#CurrentVersion, #CurrentList];

public void run()

public boolean unpack(container packedClass)
    Version version = RunBase::getVersion(packedClass);

    switch (version)
        case #CurrentVersion:
            [version, #CurrentList] =  packedClass;

            return false;

    return true;

public static MultiSelectRunBaseBatch construct()
    return new MultiSelectRunBaseBatch();

client server static ClassDescription description()
    return "Multi-select run base batch";

public static void main(Args _args)
    MultiSelectRunBaseBatch batch = MultiSelectRunBaseBatch::construct();

    if (batch.prompt())

public container warehouseIdsToRecIds(container _warehouseIds)
    InventLocation      inventLocation;
    InventLocationId    inventLocationId;
    container           warehouseRecIds;
    int                 i;

    warehouseRecIds = conNull();

    for (i = 1; i <= conLen(_warehouseIds); i++)
        inventLocationId = conPeek(_warehouseIds, i);

        select firstOnly RecId from inventLocation
        where inventLocation.InventLocationId == inventLocationId;

        warehouseRecIds += [inventLocation.RecId];

    return warehouseRecIds;

public container warehouseRecIdsToIDs(container _warehouseRecIds)
    InventLocation  inventLocation;
    RecId           inventLocationRecId;
    container       warehouseIds;
    int             i;

    warehouseIds = conNull();

    for (i = 1; i <= conLen(_warehouseRecIds); i++)
        inventLocationRecId = conPeek(_warehouseRecIds, i);
        select firstOnly InventLocationId from inventLocation
        where inventLocation.RecId == inventLocationRecId;

        warehouseIds += [inventLocation.InventLocationId];

    return warehouseIds;


About is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags