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

How to give multiselection lookup in Form level

(1) ShareShare
ReportReport
Posted on by 672
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)
  • Suggested answer
    Waed Ayyad Profile Picture
    9,089 Super User 2026 Season 1 on at
    Hi,
     
     
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • Waed Ayyad Profile Picture
    9,089 Super User 2026 Season 1 on at
    Hi,

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

    Thanks
    Waed Ayyad
  • D365FO Avatar Profile Picture
    672 on at
    Can you please suggest what need to be done in case of custom form and another approach which you have shared.
  • Suggested answer
    Waed Ayyad Profile Picture
    9,089 Super User 2026 Season 1 on at
    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
    672 on at

    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
    9,089 Super User 2026 Season 1 on at
    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
    672 on at
    [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
    9,089 Super User 2026 Season 1 on at
    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
  • Waed Ayyad Profile Picture
    9,089 Super User 2026 Season 1 on at
    Hi,

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

    Thanks
    Waed Ayyad
  • D365FO Avatar Profile Picture
    672 on at
    I have did the same way mentioned in the Blog you shared.
     
    Could you please let me know how I have to define it?

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans