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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Multi select on dialog field

(0) ShareShare
ReportReport
Posted on by 465

Hi,

So i'm trying to do multi select on dialog field. Below is what i did. The multi- select is working, and i can see that i filled 2 invoices for example but when I pass the contract to the service class, i can see the dialog has Invoice1 but Invoice2 is corrupted so if it's name was CIV-000001 I see it in the debug as CIV

Also i noticed that addLookupField is not working, it gives me all fields not only the ones i specified.

Here's what i did:

public void postRun()
{
    super();
    
    register overrides for form control events
    field1.registerOverrideMethod(methodstr(FormStringControl, Lookup),
        methodstr(InvoiceUIBuilder, lookUpfield1), this);
}

    public void lookUpfield1(FormStringControl _control)
    {
        SysTableLookup      sysTableLookup  = SysTableLookup::newParameters(tableNum(CustInvoiceJour), _control);
        Query               query           = new Query ();
        query.addDataSource(tableNum(CustInvoiceJour)).addRange(fieldNum(CustInvoiceJour, flag)).value(enum2Str(NoYes::No));
        // Add fields
        sysTableLookup.addLookupfield(fieldNum(CustInvoiceJour, InvoiceId));
        sysTableLookup.addLookupfield(fieldNum(CustInvoiceJour, InvoiceDate));


        container con;
        SysLookupMultiSelectGrid::lookup(query,_control,_control,_control,con);

        // Run lookup
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();

    }

I have the same question (1)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Most likely you are handling the value in a variable that is not long enough to hold multiple values, therefore the second value gets cropped.

    Could you use the standard query dialog (which is used on almost every batch and report dialog)? There user can select multiple values easily, on any field.

  • D365FO user Profile Picture
    465 on at

    I used CustInvoiceId in the contract, so i should use Notes EDT but the lookup will disappear that way , what should i use instead?

    u mean i should use query filter instead of contract parameter?

    i noticed that in query filter when u multi select things don't get separated by a comma so if i'm going to select alot of data this might get frustrating, is there a solution to this?

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    I think you should use the out of the box query dialog. That's used everywhere in the system so your users must be trained to get familiar with it. Yes, if multiple values are selected, your user must type comma in between the values.

  • D365FO user Profile Picture
    465 on at

    ok, i will try to see if the query approach will work for me. But for now, is there a way i can make it fit for all invoices?

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    I guess there is. Just override the lookup method of the field, then the lookup works in any way you define, regardless of EDT of the field.

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    For reference, we also discussed using a query in other threads using values coming from multiselect of a dialog and adding a new table to an existing data entity.

  • D365FO user Profile Picture
    465 on at

    Hi Nikolaos,

    i showed u in the code above the i used registerOverrideMethod for the lookup, but the multi select is getting corrupted... so is there a solution for this issue using this approach?

    and why the add lookupField is not working? it's returning all fields instead of the ones i specified?

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    I don't think you should be overriding lookup() method at all. Call SysLookupMultiSelectCtrl::constructWithQuery() from postRun(). You'll find plenty of examples in the standard application (by using "Find references").

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Could you share your full code? From the code that you shared, we don't see how the dialog field (field1) is created so it's not possible to spot if there's something that you could do differently.

    I still strongly suggest using the standard query approach which is familiar to users, works similarly across the system and doesn't require any development.

  • D365FO user Profile Picture
    465 on at

    Here's the full code of the UI builder

        DialogField field1;
    
        public void postBuild()
        {
            super();
        
            // get references to dialog controls after creation
            field1 = this.bindInfo().getDialogField(this.dataContractObject(),
                                        methodStr(Contract, parmInvoiceId));
    
        }
    
        public void postRun()
        {
          super();
        
          register overrides for form control events
          field1.registerOverrideMethod(methodstr(FormStringControl, Lookup),
             methodstr(InvoiceUIBuilder, lookUpfield1), this);
        }
    
        public void lookUpfield1(FormStringControl _control)
        {
            SysTableLookup      sysTableLookup  = SysTableLookup::newParameters(tableNum(CustInvoiceJour), _control);
            Query               query           = new Query ();
            query.addDataSource(tableNum(CustInvoiceJour)).addRange(fieldNum(CustInvoiceJour, flag)).value(enum2Str(NoYes::No));
            // Add fields
            sysTableLookup.addLookupfield(fieldNum(CustInvoiceJour, InvoiceId));
            sysTableLookup.addLookupfield(fieldNum(CustInvoiceJour, InvoiceDate));
    
    
            container con;
            SysLookupMultiSelectGrid::lookup(query,_control,_control,_control,con);
    
            // Run lookup
            sysTableLookup.parmQuery(query);
            sysTableLookup.performFormLookup();
    
        }

    and in the contract  i used custInvoiceId.

    i don't think query filter will work in my scenario, i'm still investigating this but for now i need a solution to this problem

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans