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

Announcements

No record found.

News and Announcements icon
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

  • André Arnaud de Calavon Profile Picture
    307,097 Super User 2026 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,573 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
    117 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
Martin Dráb Profile Picture

Martin Dráb 415 Most Valuable Professional

#2
CU10121822-0 Profile Picture

CU10121822-0 374

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 365 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans