Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

How to retain checkbox check in multi-selected values

Posted on by 20

Hi All,

I have created a dialog form wherein I have added a field Store number which shows a list of stores.I have made it multiselected so that whatever values I mark in the drop down shows up in the field and also it get saved in a table.

pastedimage1588744645488v1.pngpastedimage1588744717656v2.png

The problem I am facing is that whatever value I select appears in the field even after closing the form but the 'Check 'on check boxes get disappear and the below image shows how it looks when we re-open the form.

pastedimage1588744869164v3.png

Here the check mark on the Annapol and Atlanta values has gone.

Please help how can I retain these check marks with the values if the form is reopened.I have followed lot of blogs but unable to achieve this.

Please help!!!

Thanks in advance.

  • RE: How to retain checkbox check in multi-selected values

    Hello Everyone,

    Does anyone fixed the similar case in D365FO ? I have the same case, In Ax 2012 fixing the standard class SysLookupMultiSelectGrid worked but in D365FO , fixing is not possible.

    Any help or suggestion is highly appreciated.

    Thanks,

    Rama krishna Tanneeru

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: How to retain checkbox check in multi-selected values

    Hi Somesh,

    If you want to restore checkboxes in lookup based on prev. selected values, you can try to modify call for SysLookupMultiSelectCtrl::constructWithQuery.

    multiSelectCtrl = SysLookupMultiSelectCtrl::constructWithQuery(formRun, formStringControl, query, false, [tableNum(RetailStoreTable), fieldName2id(tableNum(RetailStoreTable), fieldStr(RetailStoreTable, StoreNumber))]);

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to retain checkbox check in multi-selected values

    Hi,

    next time when you share code, could you please click "Use rich text formatting - Insert - Code" so that it's easier to read. Thanks!

    About your code, you also need to change the pack/unpack methods to save/fetch the CurrentList, but at least in your previous code the pack method was missing completely. Also, please delete your usage data regarding this object and see if it helps (after fixing the code).

  • RE: How to retain checkbox check in multi-selected values

    Hi Nikolaos,

    I have already done that but no luck.

    Please help!!!

    class enableCountingSetup extends RunBase

    {

       DialogRunbase               dialog;

       DialogField                    dfStoreNum;

       DialogGroup                 dgStoreNum;

       Query                            query;

       QueryRun                      queryRun;

       QueryBuildDataSource  qbdsRetailStore, qbdsRetailChannel, qbdsOMOperating;

       FormStringControl               formStringControl;

       FormBuildStringControl       formBuildStringControl;

       FormBuildControl                formBuildControl;

       SysLookupMultiSelectCtrl    multiSelectCtrl;

       FormRun                              formRun;

       MandateCountingTable     mandateCountingTable, mandateCountingTableDel, mandCountingTable;

       RetailStoreTable            retailStoreTable;

       RecId                       storeRecIds;

       container                   storeIds;

       RetailStoreId               storeNum;

       container                   selectedStore, storeNumCon;

       #define.CurrentVersion(1)

       #localMacro.CurrentList

           storeNumCon

       #endmacro

    }

    Thanks

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to retain checkbox check in multi-selected values

    You should add the storeNumCon variable in [tag:CurrentList] in class declaration (see Tutorial_RunBaseBatch for example how to do it), and then pack/unpack it in pack/unpack methods.

  • RE: How to retain checkbox check in multi-selected values

    Hi Nikolaos,

    Below is the code snippet.

    class enableCountingSetup extends RunBase
    ***************************************************


    public static enableCountingSetup construct()
    {
    return new enableCountingSetup ();
    }
    ****************************************************
    public static void main(Args _args)
    {
    enableCountingSetup countingSetup = enableCountingSetup ();

    if (countingSetup.prompt())
    {
    countingSetup.run();
    }
    }
    ****************************************************


    public boolean unpack(container packedClass)
    {
    Version version = RunBase::getVersion(packedClass);
    switch (version)
    {
    case #CurrentVersion:
    [version, #CurrentList] = packedClass;
    break;
    default:
    return false;
    }
    return true;
    }
    ****************************************************


    protected Object dialog()
    {
    dialog = super();
    dialog.alwaysOnTop(true);
    dialog.windowType(FormWindowType::ListPage);
    dialog.allowUpdateOnSelectCtrl(true);
    dgStoreNum = dialog.addGroup();
    formBuildControl = dialog.formBuildDesign().control(dgStoreNum.name());
    formBuildStringControl = formBuildControl.addControl(FormControlType::String, identifierStr(RetailStoreId));
    formBuildStringControl.label('Store number');
    return dialog;
    }
    ****************************************************


    client server static ClassDescription description()
    {
    return 'Manadatory counting setup at store';
    }
    ****************************************************


    public void dialogPostRun(DialogRunbase _dialog)
    {
    ;

    query = new Query();
    qbdsRetailStore = query.addDataSource(tableNum(RetailStoreTable));
    qbdsRetailStore.addSelectionField(fieldNum(RetailStoreTable, StoreNumber));
    super(_dialog);
    formRun = _dialog.dialogForm().formRun();
    if (formRun)
    {
    formStringControl = formRun.design().control(formBuildStringControl.id());
    multiSelectCtrl = SysLookupMultiSelectCtrl::constructWithQuery(formRun, formStringControl, query);
    multiSelectCtrl.set([this.storeRecIdsToIDs(storeNumCon), storeNumCon]);
    }
    }
    ****************************************************


    public container storeRecIdsToIDs(container _storeRecIds)
    {
    int i;
    storeIds = conNull();
    for (i = 1; i <= conLen(_storeRecIds); i++)
    {
    storeRecIds = conPeek(_storeRecIds, i);
    if (storeRecIds)
    {
    select firstOnly StoreNumber from retailStoreTable
    order by retailStoreTable.StoreNumber asc
    where retailStoreTable.RecId == storeRecIds;

    storeIds += [retailStoreTable.StoreNumber];
    }
    }
    return storeIds;
    }
    ****************************************************


    public boolean getfromdialog()
    {
    boolean ret;
    ret = super();
    storeNumCon = this.storeRecIdsToIDs(multiSelectCtrl.get());
    return ret;
    }
    ****************************************************


    public void run()
    {
    this.setup();
    }
    ****************************************************


    public void setup()
    {
    int i;
    ;
    delete_from mandateCountingTableDel;
    for (i = 1; i <= conLen(storeNumCon); i++)
    {
    storeNum = conPeek(storeNumCon, i);
    if (storeNum)
    {
    select firstOnly mandateCountingTable
    order by mandateCountingTable.StoreNumber asc
    where mandateCountingTable.StoreNumber == storeNum;
    if (!mandateCountingTable)
    {
    mandateCountingTable.StoreNumber = storeNum;
    mandateCountingTable.insert();
    }
    }
    }
    }

    Thanks in advance!!!

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to retain checkbox check in multi-selected values

    Can you share your code?

  • RE: How to retain checkbox check in multi-selected values

    Hi Nikolaos,

    I am using runbase framework for this.Can you please help that how can I save the check marks.

    Thanks alot.

  • RE: How to retain checkbox check in multi-selected values

    Hi Sergei,

    Yes, I am using SysLookupMultiSelect class in runbase.

    Thanks

  • Blue Wang Profile Picture
    Blue Wang on at
    RE: How to retain checkbox check in multi-selected values

    Hi Somesh,

    You need to place the value you selected in the container.

    You can refer this thread:

    community.dynamics.com/.../809206

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans