15 Kasım 2017 Çarşamba

AX 2012 - Multiselect Lookup

There is a class and a sample form (tutorial_LookupMultiSelectGrid) at AOT for generate multi select lookup:

public class FormRun extends ObjectRun
{
    SysLookupMultiSelectCtrl msCtrl;
}


public void init()
{
   ...  
    super();
    ...
    
    msCtrl = SysLookupMultiSelectCtrl::construct(element, InventLocationIdExc, queryStr(InventLocationSRS));
    msCtrl.set(this.InventLocationList());
    ...
}

We can get list like below and set like up in init.

container InventLocationList()
{
    Container           Ids,Names;
    InventLocation      location;
    int i;
    RecId               recId;

    for (i=1;i<=conLen(vInventLocationIdExc);i++)
    {
        recId = conPeek(vInventLocationIdExc,i);
        select firstOnly location
            where location.RecId == recId;
        Ids += location.RecId;
        Names += location.InventLocationId;
    }

    return [Ids,Names];
}

We can save like this at Pack method:

container pack()
{
    ...
    vInventLocationIdExc    = msCtrl.get();
    ...
}

While MsCtrl.get() gives us RecId values below gives us field values:

container               c = msCtrl.getSelectedFieldValues();

Hiç yorum yok:

Yorum Gönder