web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How to give multiselection lookup in Form level

(1) ShareShare
ReportReport
Posted on by 644
Hi Folks,
 
Need to give a Multiselection option in a field of a custom form.
 
I have created a field with string size 1000 and created a Lookup method of Data field control level
 
public void lookup()
{
    //super();
  
    container conLookup;

    Query query = new Query(tableStr(CompanyInfo));

    QueryBuildDataSource queryBuildDataSource = query.addDataSource(tableNum(CompanyInfo));
    queryBuildDataSource.addSelectionField(fieldNum(CompanyInfo, DataArea));
    queryBuildDataSource.addSelectionField(fieldNum(CompanyInfo, Name));

    conLegalEntity = [tableNum(CompanyInfo), fieldNum(CompanyInfo, DataArea)];


    SysLookupMultiSelectGrid::lookup(query,
                                this,
                                this,
                                this,
                                conLegalEntity);
}
But now the issue is multiselection option is coming in the lookup but it is not showing in the field value after selection i.e No selected value is populating in the field value.
 
How can I fixed this issue
I have the same question (0)
  • Waed Ayyad Profile Picture
    8,952 Super User 2025 Season 2 on at
    How to give multiselection lookup in Form level
    Hi,
     
    I'm not getting your question? Can you please share the final code and tell me what is the issue that you 're facing now?
     
     
    Thanks
    Waed Ayyad
     
  • D365FO Avatar Profile Picture
    644 on at
    How to give multiselection lookup in Form level
    I have did the same way mentioned in the Blog you shared.
     
    Could you please let me know how I have to define it?
  • Waed Ayyad Profile Picture
    8,952 Super User 2025 Season 2 on at
    How to give multiselection lookup in Form level
    Hi,

    Is your issue resolved?  If yes, mark the answers that helped you as verified.

    Thanks
    Waed Ayyad
  • Suggested answer
    Waed Ayyad Profile Picture
    8,952 Super User 2025 Season 2 on at
    How to give multiselection lookup in Form level
    Hi,
     
    Did you define this method getSelectedLegalEntity? Where is the definition of it? Also did the build run without any errors?
     
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
  • D365FO Avatar Profile Picture
    644 on at
    How to give multiselection lookup in Form level
    [Form]
    public class abcForm extends FormRun
    {
        public SysLookupMultiSelectCtrl    msCtrl;
     
      
        public Query buildLegalEntityQuery()
        {
            Query query = new Query(queryStr(abcQuery));
            return query;
        }
    
        container buildLegalEntityQuery(DataAreaId _legalEntityStr)
        {
            CompanyInfo  legalEntity;
            container   tmpValues, conIds, conName;
            int         idx;
         
            if(_legalEntityStr)
            {
                tmpValues = str2con(_legalEntityStr, ';');
            }
         
            for(idx=1; idx<=conLen(tmpValues); idx++)
            {
                legalEntity = CompanyInfo::findDataArea(conPeek(tmpValues, idx));
                conIds += legalEntity.DataArea;
                conName += legalEntity.Name;
            }
         
            return [conIds, conName, conIds];
        }
    
        public void init()
        {
            Query  legalEntityQry = this.buildLegalEntityQuery();
    
            super();
           
            msCtrl = SysLookupMultiSelectCtrl::construct(this,
                                                Grid_LegalEntity,
                                                queryStr(abcQuery),
                                                false,
                                                [tableNum(CompanyInfo), fieldNum(CompanyInfo, DataArea)]);
     
            msCtrl.refreshQuery(legalEntityQry);
            msCtrl.set(this.getSelectedLegalEntity(abcTable.LegalEntity));   
           
        }
    
        [DataSource]
        class abcTable
        {
            [DataField]
            class LegalEntity 
            {
                
                public void modified()
                {
                   // super();                
     
                    abcTable.LegalEntity     =   con2Str(msCtrl.getSelectedFieldValues(), ';');
                }
            }
        }
    }
  • Suggested answer
    Waed Ayyad Profile Picture
    8,952 Super User 2025 Season 2 on at
    How to give multiselection lookup in Form level
    Hi,
     
    Try to do full build for your model. Also did you add third step: "3. Create a parm method to hold the multilookupSelectCtrl object" and did you set the value of  the parm method on the init method? Can you share the code ?
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • D365FO Avatar Profile Picture
    644 on at
    How to give multiselection lookup in Form level

    I have added all the method which is given in the link, here also multiselection option is coming but the selected value is not  populating.
    I have debugged and checked at time of selection in field, modified method is not triggering. 
        [DataSource]
        class dataSource
        {
            [DataField]
            class fieldName
            {           
                public void modified()
                {
                   // super();                
     
                    dataSource.fieldName     =   con2Str(msCtrl.getSelectedFieldValues(), ';');
                }
            }
        }

    Please suggest me what can be the issue
  • Suggested answer
    Waed Ayyad Profile Picture
    8,952 Super User 2025 Season 2 on at
    How to give multiselection lookup in Form level
    Hi,
     
    You can follow the same concept in the following link: Multi select lookup in D365 FO (dynamics.com) but instead of using COC and Event handler you will add your code directly on the init method of the form and modified method of your multi lookup control.
     
    Follow it and tell me if you faced any issue.
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
     
     
  • D365FO Avatar Profile Picture
    644 on at
    How to give multiselection lookup in Form level
    Can you please suggest what need to be done in case of custom form and another approach which you have shared.
  • Waed Ayyad Profile Picture
    8,952 Super User 2025 Season 2 on at
    How to give multiselection lookup in Form level
    Hi,

    Is your issue resolved?  If yes, mark the answers that helped you as verified.

    Thanks
    Waed Ayyad

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,351

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 638 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans