Planning to show a custom multi-select lookup. Use the Xrm.Utility.lookupObjects to show a multi-select lookup control in Dynamics 365

Recently in my project I had the requirement to show up a multiselect lookup for selecting records across multiple custom entities. The customer have created a PCF control where they have designed to show the selected records spanning entities. But the issue was to show a lookup control to allow the user to select multiple records spanning entities.

Thankfully there is a method now to do exactly the same using Client API.

The below code shows how to show up a multiselect lookup control from account and contact entity. However you can do the same for all custom entities.

var lookupOptions = {};
lookupOptions.allowMultiSelect = true;
lookupOptions.defaultEntityType = “account”;
lookupOptions.entityTypes = [“account”, “contact”];

Xrm.Utility.lookupObjects(lookupOptions).
    then(function (s) {
       if (s !== null && s.length > 0) {
          for (var x = 0; x < s.length; x++) {
             // get the type, name and id.
             var type = s[x].entityType;
             var name = s[x].name;
             var id = s[x].id;
          }
       }
    }, function (e) {
       console.log(e.error.message);
    }
    );

Below is how it looks.

image

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Notes Manager (https://debajmecrm.com/add-metadata-to-your-notes-and-attachments-in-dynamics-notes-metadata-manager-from-xrmforyou-com/)

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

This entry was posted in Dynamics 365, Microsoft CRM, Microsoft Dynamics CRM and tagged Dynamics 365, powerapps, relationship behavior, rollup, rollup view on May 23, 2020.

2 thoughts on “Planning to show a custom multi-select lookup. Use the Xrm.Utility.lookupObjects to show a multi-select lookup control in Dynamics 365”

Comments are closed.