Please wait, loading...

 

Multiselect Lookup control PCF now available in Dynamics 365 CRM

September 14, 2021

Introduction:

With the release of Power Apps Component Framework, the focus has now drastically shifted to designing a UI that is intuitive to use and especially ones that require minimal clicks to get going. N:N relationships has long been a touchy topic here where if you would like to associate more than one records 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 form.

Need:

Overtime MSFT updated the N:N sub-grids to allow quickly 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 pcf.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

Show me how to use it:

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 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 Text field with the max length as 4000.

Next switch to classic form designer and add the Approvers field to the form and here we will configure this field to use the multiselect lookup control. Edit the approvers field on the form and 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 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 lookup to. In an N:N relationship this would have been the other entity of the relationship. In our example we will set it to systemuser as we need to allow 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 to 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 would 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

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

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

Conclusion:

While this control does provide a native multiselect 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.

sharepoint security sync

Go to Source and hit them a thumps up

https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/Microsoftdynamics365.png?fit=640%2C651
Microsoft Dynamics Community Profile

Learn more