Multiselect Lookup control PCF now available in Dynamics 365 CRM

By | September 14, 2021

Introduction:

With the release of the Power Apps Component Framework, the focus has now drastically shifted to designing a UI that is intuitive to use especially one that requires minimal clicks to get going. N: N relationships have long been a touchy topic, here, where if you would like to associate more than one record with another record, the solution was designing a native N: N relationship between the 2 tables which created an intermediary table and with that, the UI presented was that of a sub-grid that could be added to the form.

Requirement:

Over time Microsoft updated the N: N sub-grids to allow quick inline adding of the records quickly without the need for the full-blown form. And yet that has not been the ideal solution for end users that usually require the ability to go ahead and select all associated records in one go and click an ok to have them set. Since the availability of PCF, many community solutions that provide a multi-select interface for N: N records have been made available and you can browse through them at Gallery

We were pleasantly surprised to find a Multiselect Lookup control OOB with a CRM trial we were working on.

Multiselect Lookup Control PCF

Looks like it is being shipped as part of field service (found the tech control name when it crashed and showed an error). In case you don’t find it in your environment this could be the reason.

8Multiselect Lookup Control PCF

How it is used:

There isn’t a document available for it, but it is easy to get started with this control. Let us take a scenario where we have to allow for the selection of multiple users who would act as approvers for a Quote. Traditionally it would have been an N: N relationship between Quote and System User tables. To explore this control, we instead decide to add a text field. Note this control is only available to be configured for fields of the type Single Line Text.

We added the Approvers field to the Quote table as a Text field with a max length of 4000.

Next switch to classic form designer and add the Approvers field to the form here we will configure this field to use the multi-select lookup control. Edit the approvers field on the form move to the controls tab in field properties and choose Add Control as shown below:

Multiselect Lookup control PCF

Select the MultiSelectLookupControl from the list and choose Add to bring you back to the following screen:

Multiselect Lookup Control PCF

Configure the control to be displayed on the Web interface and/or Phone and Tablet based on your preference.

Let us now check the properties that need to be set for this control. The property names are not too descriptive but here is what you need to provide for each of them:

entityName – The logical name of the entity that you want to look up to. In an N: N relationship this would have been the other entity of the relationship. In our example, we will set it to the system as we need to allow the selection of multiple Users as approvers for the quote.

Multiselect Lookup control PCF-

defaultViewId – Since this is going to provide you with a lookup control for the entity specified above, we need to also provide the default view that is used to show the selection list in the lookup interface. To get the view ID, you can navigate to the home page of the entity and choose the view. The id of the selected view is reflected in the URL. Not user friendly but that is how it is for now.

Multiselect Lookup Control PCF

And you are done. Save and publish the form to see the lookup control in action with the same native lookup experience on the quote form.

multiselect lookup control PCF

Once you have made all the selections, the user interface will update to show as following.

Multiselect Lookup Control PCF

Do note however that behind the scenes, this is being stored in JSON format which is not user-friendly and would require dev experience to parse and use the information for purposes other than displaying it on a form.

If you add this field to the view, it will display the data in JSON array format. Since we are not allowed to configure a PCF control for a grid column as yet, you will not be able to provide the descriptive names of the selected records in this column.

Multiselect Lookup Control PCF

The same is the case if these need to be included in Reports or Power Automate flows – you will need some parsing logic to parse out the descriptive names or record IDs for processing.

And since it is stored in JSON format, make sure that the text column that is being used has been set to a max length of 4000 this is another limitation where with 4000 being the max limit there is only a limited count of related records that can be associated.

Conclusion

While this control does provide a native multi-select lookup experience that users of Dynamics 365 CRM and Dataverse are familiar with, you do need to take into account the fact that using this control entails developer experience for any further utilization of the data stored in these fields.

Cut short 90% of your manual work and repetitive data entry!

Get 1 Click apps and say goodbye to all repetitive data entry in CRM –
Click2Clone – Clone/Copy Dynamics 365 CRM records in 1 Click
Click2Export – Export Dynamics 365 CRM Report/CRM Views/Word/Excel template in 1 Click
Click2Undo – Undo & Restore Dynamics 365 CRM data in 1 Click