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

Multiselect lookup on a string control in SysOperation dialog doesn't hit modified method

(1) ShareShare
ReportReport
Posted on by 102
Hi
 
I have a dialog created using SysOperation framework where I have two string fields with overriden multiselect lookups.
 
Example:
FieldA values: parent1, parent2, parent3
FieldB values: child11, child12, child21, child31, child32, child33
 
And when I select for example parent3, I want other lookup to be populated with values: child31, child32, child33
What I did is I have overriden postBuild method (I tried also in postRun):
 
dlgFieldA.registerOverrideMethod(
      methodStr(FormStringControl, modified),  
      methodStr(MyTestUIBuilder, updateOtherLookup),
      this);
 
But the problem is that when I select values it doesn't hit modified method at all, It only hits when I manually type the value in the field (for example parent2) and in that case it works.
 
How can I achieve that it hits modified when I do a selection from the lookup? Should I override some other method and not modified?
 
Thanks in advance
I have the same question (0)
  • Suggested answer
    Assisted by AI
    Deepak Agarwal Profile Picture
    8,917 on at
    Hello, In sysoperation frmework, there is one more class, called UI builder. To acheive your expected result you need to explore this class. 
     
    Here is some reference code, (Drived from Copilot)
    public class MyTestUIBuilder extends SysOperationAutomaticUIBuilder
    {
        DialogField                 dlgFieldA, dlgFieldB;
        SysLookupMultiSelectCtrl    msFieldA, msFieldB;
    
        public void postBuild()
        {
            super();
    
            dlgFieldA = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(MyContract, parmFieldA));
            dlgFieldB = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(MyContract, parmFieldB));
    
            // Build multi-select controller for FieldA
            msFieldA = SysLookupMultiSelectCtrl::constructWithQuery(
                this.dialog().formRun(),
                dlgFieldA.control(),
                this.queryForParents()
            );
    
            // IMPORTANT: Trigger when user confirms selection in lookup
            msFieldA.registerOverrideMethod(
                methodStr(SysLookupMultiSelectCtrl, closeOk),
                methodStr(MyTestUIBuilder, fieldA_closeOk),
                this
            );
    
            // FieldB controller (initially empty or default)
            msFieldB = SysLookupMultiSelectCtrl::constructWithQuery(
                this.dialog().formRun(),
                dlgFieldB.control(),
                this.queryForChildren("") // no parent yet
            );
        }
    
        private void fieldA_closeOk(SysLookupMultiSelectCtrl _ctrl)
        {
            // Let base behavior apply the value first
            next fieldA_closeOk(_ctrl);
    
            // Now read selected parents and update FieldB lookup
            this.updateOtherLookup();
        }
    
        private void updateOtherLookup()
        {
            str selectedParents = dlgFieldA.value(); // multi-select string like "parent3;parent2" depending on your setup
    
            Query q = this.queryForChildren(selectedParents);
    
            // Rebind FieldB multiselect with new query
            msFieldB.setQuery(q);
    
            // Optional: clear FieldB selection because available children changed
            dlgFieldB.value("");
        }
    
        private Query queryForParents()
        {
            Query q = new Query();
            QueryBuildDataSource qbds = q.addDataSource(tableNum(MyParentTable));
            // add ranges/sorting as needed
            return q;
        }
    
        private Query queryForChildren(str _selectedParents)
        {
            Query q = new Query();
            QueryBuildDataSource qbds = q.addDataSource(tableNum(MyChildTable));
    
            // Apply range based on selected parent(s)
            // If your multi-select string uses a delimiter, parse it and apply ranges accordingly.
            // Example assumes child table has ParentId field.
            if (_selectedParents)
            {
                // simplest: if only one parent expected:
                // qbds.addRange(fieldNum(MyChildTable, ParentId)).value(queryValue(_selectedParents));
    
                // If multiple parents: build an IN-style range string
                // e.g. (ParentId == "parent1") || (ParentId == "parent3")
                qbds.addRange(fieldNum(MyChildTable, ParentId)).value(this.buildOrRange(_selectedParents));
            }
    
            return q;
        }
    
        private str buildOrRange(str _multiSelect)
        {
            // Adjust delimiter based on your multi-select format
            List parts = Global::strSplit(_multiSelect, ';');
            ListEnumerator le = parts.getEnumerator();
            str range;
    
            while (le.moveNext())
            {
                str p = le.current();
                range += range ? strFmt(" || (%1 == %2)", fieldStr(MyChildTable, ParentId), queryValue(p))
                               : strFmt("(%1 == %2)", fieldStr(MyChildTable, ParentId), queryValue(p));
            }
    
            return range;
        }
    }
     
  • Suggested answer
    Martin Dráb Profile Picture
    239,547 Most Valuable Professional on at
    Copilot is kidding; the code  wouldn't even  compile. Please check the correctness of AI-generated replies before  sharing them.
     
    Note that there isn't any code needed in the UI builder to get a multi-selection lookup, because the automatic UI builder already creates UI with multi-selection for collection members of the data contract.
     
         
    devgirlX, I think the actual problem is that your  other lookup tries to access the string value of the original field, which is shouldn't. It should call getSelectedFieldValues() of SysLookupMultiSelectCtrl. If you're using the default framework implementation, you can call getMultiSelectFromDialogField() of your UI builder class, which returns the values  as a single  string, or get  the SysLookupMultiSelectCtrl instance by calling multiSelectControlMap.lookup() and then calls its getSelectedFieldValues() method. It depends on what you want to do with the value.     
                

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... 661 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 620

#3
Subra Profile Picture

Subra 473

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans