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, ...
Answered

Changing lookup values based on selection of other lookup values

(1) ShareShare
ReportReport
Posted on by 12
Based on this multiselect lookup (Item Group) i want ItemId related to this groups in other Lookup in a Report.
so please guide me how to write a code in a UI Builder class for this 
 
 
 
 
I have the same question (0)
  • Martin Dráb Profile Picture
    239,451 Most Valuable Professional on at
    What is the particular problem you're struggling with?
     
    Do you mean that you know how to create a lookup but not how to use item groups in the query? Or that you know how to create a lookup but not how to use it in UI builder class? Or that you aren't familiar with lookup methods at all? Or is it something else.

    (Moved from Dynamics AX forum.)
  • Verified answer
    Waed Ayyad Profile Picture
    9,135 Super User 2026 Season 1 on at
    Hi,
     
    but as Martin asked you, we should know what is the issue that you faced?
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • CU25081303-1 Profile Picture
    12 on at
    I was working with multiselect lookup so i don't know how to work with that so i tried this code in UIBuilder class but was not showing ItemId related to selected ItemGroup.
     
     public void postRun()
        {
             QueryBuildDataSource     qbds;
            QueryBuildRange             qbr;
          
            str curCompany;
            curCompany = curExt();
     
            Query       query3               = new Query();
            qbds = query3.addDataSource(tableNum(InventItemGroupItem));
            qbds.addGroupByField(fieldNum(InventItemGroupItem,ItemGroupId));
            
            qbr = qbds.addRange(fieldNum(InventItemGroupItem, ItemGroupDataAreaId));
            qbr.value(curCompany);
            container   selecteditemgroup    = [tableNum(InventItemGroupItem), fieldNum(InventItemGroupItem, ItemGroupId)];
            SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(),dialogitemGroup.control(),query3, true, selecteditemgroup);

            Query       query4                = new Query();
            QueryBuildDataSource     qbdss;
            int i ;
           
            qbdss = query4.addDataSource(tableNum(InventItemGroupItem));
            qbr=qbdss.addRange(fieldNum(InventItemGroupItem, ItemGroupDataAreaId));
            qbr.value(curCompany);
            if (conLen(selecteditemgroup) > 0)
            {
                qbr = qbdss.addRange(fieldNum(InventItemGroupItem, ItemGroupId));
                str rangeValue = '';
                for (i = 1; i <= conLen(selecteditemgroup); i++)
                {
                    if (i > 1)
                    {
                        rangeValue += ',';
                    }
                    rangeValue += conPeek(selecteditemgroup, i);
                }
                qbr.value(rangeValue);
            }
            container   selecteditemId     = [tableNum(InventItemGroupItem), fieldNum(InventItemGroupItem, ItemId)];
            SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(),dialogitemId.control(),query4, true, selecteditemId);
                                            
        }
  • Martin Dráb Profile Picture
    239,451 Most Valuable Professional on at
    Is the problem resolved? You marked Waed's reply as the verified answer, but then you showed us a piece of code without an explanation. Does it mean that you're sharing the working solution?
     
    By the way, your code will be much easier to understand if you start giving variables meaningful names and give blocks of code names (= creating methods). It's important for you as well; you'll want to understand code that you wrote years ago.
  • CU25081303-1 Profile Picture
    12 on at
    no it dosen't solve my problem but i am trying right now

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 593 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 543

#3
CP04-islander Profile Picture

CP04-islander 430

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans