web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

how to refresh multi selected lookup in form control ?

(0) ShareShare
ReportReport
Posted on by 932

Hello, 

I   add multi selected lookup to a field in datasource ,

when Iopen form and I create new record , i get the lookup, I chose values 

But the problem is when I add second record , I get the same values selected as the first in lookup

[Form]
public class ShippingModeTable extends FormRun
{
    
    SysLookupMultiSelectCtrl    msCtrl;
    public Query buildDlvModeQuery()
    {
        Query       dlvModeQry = new Query(queryStr(ShippingModeLookup));
        return dlvModeQry;
    }

    container getSelectedCodes(str _codeStr)
    {
        DlvMode    dlvMode;
        container   tmpValues, conIds, conName;
        int         idx;
     
        if(_codeStr)
        {
            tmpValues = str2con(_codeStr, ';');
        }
     
        for(idx=1; idx<=conLen(tmpValues); idx  )
        {
            dlvMode = DlvMode::find(conPeek(tmpValues, idx));
            conIds  = dlvMode.RecId;
            conName  = dlvMode.Code;
        }  
        return [conIds, conName, conIds];
    }

    [DataSource]
    class ShippingModeTable
    {
        [DataField]
        class ShippingMode 
        {
            /// 
            ///
            /// 
            public void modified()
            {
                ShippingModeTable    shippingModeTable    = ShippingModeTable_ds.cursor();   
                shippingModeTable.ShippingMode     =   con2Str(msCtrl.getSelectedFieldValues(), ';');
                ShippingModeTable_ds.refresh();
                ShippingModeTable_ds.research(true);
            }

            public void lookup(FormControl _formControl, str _filterStr)
            {
                //super(_formControl, _filterStr);
                Query               dlvModeQry         =   element.buildDlvModeQuery();
                FormStringControl   shippingMode        =   element.design().controlName('ShippingModeTable_ShippingMode');
                EOLEShippingModeTable    shippingModeTable    =   ShippingModeTable_ds.cursor();
                msCtrl   = SysLookupMultiSelectCtrl::construct(element,
                                            shippingMode,
                                            querystr(ShippingModeLookup),
                                            false,
                                            [tableNum(DlvMode), fieldNum(DlvMode,Code)]);
                  msCtrl.set(element.getSelectedCodes(shippingModeTable.ShippingMode));
                ShippingModeTable_ds.refresh();
                ShippingModeTable_ds.research(true);
            }

        }

    }

}


pastedimage1677313643600v1.png

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,025 Super User 2025 Season 2 on at

    Hi Basma,

    Is the coding you shared all the coding related to this lookup? Have you implemented coding to update the selected values on the active() method of the data source?

    Do you only have Shipping mode field on this table (where you store the selection in a string field) or also an additional table to store the relations between this table and the Mode of delivery?

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi Basma,

    Check this article, try aligning with code mentioned there.

    erpdax.wordpress.com/.../

  • BASMA Profile Picture
    932 on at

    hello,

    Andre Arnaud de Calavon , no I have 3 fields in table , I store  the selection in a string field

    then this is all the code that I add it .

    Mohit Rampal , I see this code and I use it , the problme with this code is how to set the eventHandler npt static

  • HARISH MEHRA Profile Picture
    113 on at

    Hello BASMA did you get the answer. Because I am also facing the same issue.

    Help will be appreciated.

  • BASMA Profile Picture
    932 on at

    hello HARISH MEHRA 

    sorry for the late response ,

    Yes, I found a solution

    [Form]
    public class ShippingModeTable extends FormRun
    {  
        SysLookupMultiSelectCtrl    msCtrl;
        ShippingModeTable    shippingModeTable;
        /// 
        /// get the  mode od delivery from dlvMode Table
        /// 
        /// 
        /// container of selected element in lookup
        container getSelectedCodes(str _codeStr)
        {
            DlvMode    dlvMode;
            container   tmpValues, conIds, conName;
            int         idx;    
            if(_codeStr)
            {
                tmpValues = str2con(_codeStr, ';');
            }   
            for(idx=1; idx<=conLen(tmpValues); idx  )
            {
                dlvMode = DlvMode::find(conPeek(tmpValues, idx));
                conIds  = dlvMode.RecId;
                conName  = dlvMode.Code;
            }
            return [conIds, conName, conIds];
        }
    
        public void init()
        {
            super();
            msCtrl   = SysLookupMultiSelectCtrl::construct(element,
                                                ShippingModeTable_ShippingMode,
                                                querystr(ShippingModeLookup));
        }
    
        [DataSource]
        class ShippingModeTable
        {
            /// 
            ///update lookup's values
            /// 
            /// 
            public int active()
            {
                int ret;       
                ret = super();
                shippingModeTable    =   ShippingModeTable_ds.cursor();
                msCtrl.set(element.getSelectedCodes(shippingModeTable.ShippingMode));
               return ret;
            }
    
            [DataField]
            class ShippingMode 
            {
                /// 
                /// update values in ShippingModeTable
                /// 
                public void modified()
                {
                    shippingModeTable.ShippingMode     =   con2Str(msCtrl.getSelectedFieldValues(), ';');
                }
    
            }
    
        }
    
    }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans