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

Multi select Lookup (Refresh Issue in Multi Select Ctrl)

(1) ShareShare
ReportReport
Posted on by 10
Hi All , 
 
I have create a form where we have multiple string control on the selection of the value next string control value need to been filter . 
Hence when i open the form everything work as expected . But when i go an change the value from the first control . Value in the second control is showing the older value
 
 
Requested to provide some guidance to fix the issue . 
 
 
Code written on the form control 
 
Company  lookup and modified

        public void lookup()
        {
            Query query = new Query();
            QueryBuildDataSource qbds = query.addDataSource(tableNum(DATAAREA));
            qbds.clearRanges();
            qbds.addSortField(fieldnum(DATAAREA, ID));
            qbds.addOrderByField(fieldnum(DATAAREA, ID));
            qbds.orderMode(OrderMode::GroupBy);
            qbds.addSelectionField(fieldNum(DATAAREA,ID));
            msctrlcompany = SysLookupMultiSelectctrl::constructWithQueryRun(element,Company,query,false,selectedField);
            super();
        }
        /// <summary>
        /// modified method 
        /// </summary>
        /// <returns></returns>
        public boolean modified()
        {
            boolean ret;
        
            ret = super();
            CustGroup.enabled(true);
            CustGroup.text("");
            return ret;
        }
 
Code on the CustomerGroup 
 
 public void lookup()
 {
     Query query = new Query();
     QueryBuildDataSource qbdsCustomer;
     qbdsCustomer= query.addDataSource(tableNum(CustGroup));
     qbdsCustomer.clearRanges();
     List listCompany;
     ListIterator itrCompany;
     listCompany = new List(Types::String);
     listCompany = strSplit(Company.valueStr(),";");
     itrCompany = new ListIterator(listCompany);
     while(itrCompany.more())
     {
         qbdsCustomer.addRange(fieldNum(CustGroup, DataAreaId)).value(queryValue(itrCompany.value()));
         itrCompany.next();
     }
     qbdsCustomer.addSelectionField(fieldNum(CustGroup, CustGroup));
     selectedField1 = [tableNum(CustGroup), fieldNum(CustGroup, CustGroup)];
     mmsctrlcompanyGroup= SysLookupMultiSelectCtrl::constructWithQuery(element,CustGroup,query,false,selectedField1);
     super();
 }
 
Categories:
  • Anton Venter Profile Picture
    21,240 Super User 2026 Season 2 on at
    Hi,
     
    If I understand correctly, it appears that when you change the text manually in the Company field, the code in the modified method is not executed to clear the value in the CustGroup field? Can you give more information?
  • CU26100919-0 Profile Picture
    10 on at
    Hi Anton , 
     
    Thanks for the reply . 
     
    The issue which I have now . I have two string control Company and CustGroup . When form is open at first time and when i get the input in the company string control (USMF, INX) the value in custgroup get filter i am to get the customergroup (Iconix, Xyz) but when i go back and changes the select in company control ( INX) it still show the all the value  in customer group which i have selected at the first time
     
    Though the query is not getting refersh and even when i tried to debugee the second time lookup method also not called .
     
    When i check the code in debugging i found that the query in this method is not getting the new query 
     
     public void ctrlNames_lookup(FormStringControl _fsCtrlNames)
     {
         SysLookupMultiSelectGrid::lookup(query, fsCtrlNames, fsCtrlIds, fsCtrlNamesTmp, selectField, queryRun);
         this.ctrlNames_textChange(_fsCtrlNames);
     }
     
     
  • CU26100919-0 Profile Picture
    10 on at
    I have made some changes in Code . 
     
    I am getting this error now .I have followed this blog 
     
    Queries with multiple top level data sources cannot be applied to Forms.
     
    Made the changed are below 
     
    init method 
     public void init()
     {
         super();
         locationQueryRun =  new QueryRun(locationquery);
         mscustomerGroupCtrl   = SysLookupMultiSelectCtrl::constructWithQueryRun(element, CustGroup, locationQueryRun);
     }
     
    modified
    public boolean modified()
    {
        boolean ret;
        ret = super();
        CustGroup.enabled(true);
        CustGroup.text("");
        locationquery = locationQueryRun.query();
        QueryBuildDataSource qbds;
        qbds = locationquery.addDataSource(tableNum(CustGroup));
        qbds.clearRanges();
        List listCompany;
        ListIterator itrCompany;
        listCompany = new List(Types::String);
        listCompany = strSplit(Company.valueStr(),";");
        itrCompany = new ListIterator(listCompany);
        while(itrCompany.more())
        {
            qbds.addRange(fieldNum(CustGroup, DataAreaId)).value(queryValue(itrCompany.value()));
            itrCompany.next();
        }
        qbds.addSelectionField(fieldNum(CustGroup,DataAreaId));
        mscustomerGroupCtrl.refreshQueryRun(locationQueryRun);
        return ret;
    }
     
    Can please any one let know what wrong i am doing 
     
  • Suggested answer
    Anton Venter Profile Picture
    21,240 Super User 2026 Season 2 on at
    Please add your code in the forum posts using the Insert Code Snippet button. You may edit your existing posts too :-).
     
    By the way, I have moved your post to the Finance forum because I can see from your screenshot it's not AX 2012.
     
    In a scenario like this, the lookup in the customer group field should use the selected values from the company field. What I understand from your post,  is when you change the company field values, the previous customer groups values are shown in the lookup and not the customer groups related to the new company values. Or something to this effect.
     
    It appears that your customer group lookup query is not updated before the customer group lookup form is shown. To fix this, I suggest the following, make sure:
    • that the customer group field is cleared when the company field is changed.
    • that the customer group lookup query is updated to use the updated company field values before it is shown.
  • Layan Jwei Profile Picture
    8,329 Super User 2026 Season 2 on at
    Hi,
     
    Are those controls bound to a datasource or un-bounded?
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    Lets make it simple.
     
    Your requirement is based on legal entity selected, the customer groups should be filtered.
     
    So, put a hard coded range in customer group multi select and check. Ideally it will work. Then I believe you made or this report will have a UI Builder. So pick the value of company ID from the dialog field, and this value could be multi or single select for company too depends on your requirement. 
     
    Based on that check you are able to info the values by modifying the company field.
     
    If this step is also done, then use the dialog field directly and put it in range and cross check the query what is getting returned. Ideally the query will refresh.
     
    Let us know once these things are done and still if you are facing challenge.

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 August 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 523 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
CU10121822-0 Profile Picture

CU10121822-0 354

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans