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 :
Microsoft Dynamics AX (Archived)

using range in query in multi select lookup

(0) ShareShare
ReportReport
Posted on by 504

hi all,

i have two look ups in form. i want to show value in 2nd lookup which is multi select enabled based on the selection of first lookup. but range is not working in multi select enabled lookup but it is working fine if i don't use multi select lookup. 

here's the screen shot. 

8737.error.png

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    It is because you are adding a range during the initialization of the form, and you have no value at that time.

    You have to reconstruct the lookup each time the value is modified in the first control, refer to the solution at the bottom of this thread:

    dynamicsuser.net/.../how-to-use-class-syslookupmultiselectctrl-and-method-refreshqueryrun-dynamics-ax-2012

  • xain Profile Picture
    504 on at

    hi Vilmos,

    thnks for replying. i understand what u are saying. but i can't find solution on the given thread. could u help me if u can explain a little more.

    Thnks

  • Vilmos Kintera Profile Picture
    46,149 on at

    See Mathias's reply in the thread, the example is very clear by having InventSiteId as the filter criteria for InventLocation (showing warehouse entries based on the site selected). He says that you need to re-construct the 2nd lookup in the modified method of the first lookup's form control.

  • xain Profile Picture
    504 on at

    Vilmos,

    i am getting confused in what should i do in second control. should i create lookup method in 2nd control or any thing else??

    thnks

  • Verified answer
    Vilmos Kintera Profile Picture
    46,149 on at

    Let me quote the answer.

    Form init method:

    locationQueryRun =  new QueryRun(query);
    msCtrlLocation   = SysLookupMultiSelectCtrl::constructWithQueryRun(element, FilterInventLocationId, locationQueryRun);
    


    modified method on InventSiteId:

    query = locationQueryRun.query();
    qbds = query.dataSourceTable(tableNum(InventLocation));
    qbds.clearRange(fieldNum(InventLocation, InventSiteId));
    ....
    qbds.addRange(fieldNum(InventLocation, InventSiteId)).value(SysQuery::value(siteId));
    ....
    msCtrlLocation.refreshQueryRun(locationQueryRun);


    The InventSiteId in this case stands for the first field for which you need to hook up a modified method on your form control or datasource field, in order to pass on the new selected value as a range to the second control/dialog field.

  • xain Profile Picture
    504 on at

    i did as suggested. but i am getting error. when i run the form first time it is woeking fine but as soon as i change value 2nd time it gives me error. i am attaching screen shots which will further elaborate. 7266.error3.png7266.error3.png

  • Verified answer
    Vilmos Kintera Profile Picture
    46,149 on at

    Your datasource handling is incorrect. Use SysQuery::findOrCreateDataSource() static method instead of calling addDatasource on the object, which will not create duplicates, like your code is trying to. https://msdn.microsoft.com/en-us/library/sysquery.findorcreatedatasource.aspx

  • xain Profile Picture
    504 on at

    Vilmos,

    thnks a bunddle for helping. it is working now after your suggestion.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans