Byron Dittberner | image displaying multiple accounts being selected

Have you ever needed to configure a multiselect lookup? Recently while working on a Dynamics 365 implementation, I was asked to create a dropdown that has the following features.

Customer Specific Requirements

  • A user should be able to select more than one item from the dropdown
  • The dropdown would contain in excess of 100 items
  • A system user should be able to add items to the options without the need for a developer
  • A user should be able to search the options
  • Option should be sorted alphabetically

When reading the requirements, you may think this could be implemented with a standard Choices (multi-select) column, however, some of the expected features will not be possible while others will be difficult to manage, particularly the ability for a user to manage the list of options which would require the user(s) to have access to the PowerApps maker.

Review the requirements

The ideal solution would be a lookup column that a user can select more than one record. Let’s review the requirements and confirm which of them are supported by a lookup column;

  • A user should be able to select more than one item from the dropdown
    • Standard lookup columns do not support multiple select.
  • The dropdown would contain in excess of 100 items
    • With a high number of options to select from, a lookup would be the preferred solution.
  • A system user should be able to add items to the options without the need for a developer
    • In order for a user to access updating a Choice(s) column they would require access to the PowerApps maker environment which is not advisable. It is much better to have large lists managed through lookup reference tables.
  • A user should be able to search the options
    • Search and filtering are only available with lookups further confirming that lookups would be the preferred approach.
  • Option should be sorted alphabetically
    • This is something Choices(multi-select) columns do not do very well, in fact, once the list of options is created the order cannot be changed, that is without script of course. Lookups use views to display the options and we all know that view filtering is completely configurable.

Well, there is good news. You may not have known but there is a built-in component that is shipped with Dynamics 365 Field Service that enables system administrators and customizers to configure a multi-select lookup.

The setup is rather simple and does not require any code. I will explain step-by-step how to configure the lookup.

How to configure multiselect lookup

Please note that the component (MultiSelect LookUp) is shipped with Dynamics 365 Field Service and is not available in a PowerApps only environment. For alternatives in case you do not have Field Service installed, check out this PCF control.

Scenario – We will use a simple use case to demonstrate how to configure the multi-select lookup. Let’s assume you would like to associate more than one account to a contact using a multi-select lookup.

Follows these steps on how to configure a multiselect lookup

  1. Login into the PowerApps Maker
  2. Confirm that you have selected the correct environment that has Dynamics 365 Installed.
  3. Select Data on your navigation, the select Tables
  4. Select the Contact table

5. Create a new column called Accounts, be sure to set the properties as follows as per the images on the right. Click on save once you are done.

Display name: Accounts, Data Type: Text, Advanced settings – Max Characters: 4000

6. Next add the Accounts column to the Contact Main Form, then click on Save and Publish.

Select the image on the right to view a sample.

Byron Dittberner | Add the accounts field to the form

7. Next, we will need to add the multi-select control to the form. At the time I write this article, the component was not available in the modern maker experience so you will need to click on Switch to Classic.

Select the image on the right to view a sample

Byron Dittberner | switch to the classic editor

8. Double click on the Accounts column to open the field properties, then select the controls tab.

Select the image on the right to view a sample

Byron Dittberner | set the field properties

9. Click on Add Control, the scroll down and look for the Multiselect Lookup Control, select it and then click on Add

Select the image on the right to view a sample

Byron Dittberner | set the multi select control

10. Before you are able to configure the control, you will need to get the view id for Active Accounts. To do this, open a new browser tab and open a new session of the PowerApps maker. Confirm that you are in the correct environment. Open one of the Dynamics 365 apps, then select Accounts on your navigation. Ensure you have set the view to Active Accounts. Copy the viewid from the URL. Save the view id.

Click on the picture on the right to view a sample

Byron Dittberner | Select the view id from the active accounts

11. Next, you will need to configure the properties for the control. By default, the Property_Display_Key should already be populated. Click on the pencil icon next to entityName_Display_Key, select Bind to Static Value and then set the SingleLine.Text property to account (all lower case). Next, set the viewidDisplay_Desc_Key to the viewid you copied in the previous step.

Click on the image on the right to view a sample

Byron Dittberner | configure the lookup control

12. View the picture on the right and confirm your settings look the same. Please note that the view id will most likely be different. Ensure you set the control to be visible for Web.

Once you have confirmed that your settings are correct, click on Ok and the dialog box will close.

Byron Dittberner | How to create a multiselect lookup in Dynamics 365

You are nearly done, finally you should publish the changes. While still in the classic editor, click on Save, then click on Publish. Once published, click on Save and Close. Once the classic editor closes, you should be viewing the Contact Form in the PowerApps Maker. DO NOT CLICK ON SAVE! you need to refresh the browser (press Ctrl + F5). If you click on save without refreshing, your changes will be undone because the changes you made were done in a different session.

Time to test the control. Refresh the Dynamics 365 App and your new multi-select lookup should be displayed. try it out and select more than one account and click on save. View the images below for sample of the completed solution.

Byron Dittberner | How to create a multiselect lookup in Dynamics 365
This is how multiple accounts will display, click on the number (+3) next to the account name to view the entire list of accounts.
Byron Dittberner | How to create a multiselect lookup in Dynamics 365
This is how multiple selected accounts will be displayed.

Thats it, simple as that you now know how to configure a multiselect lookup. There is one snag though, if you add the Accounts column to a view the text that is displayed in a JSON blob which is nasty. So, my advice, do not add this field to a view. I will be publishing an article explaining how to display the list of selected accounts in a multiline text column where each account is comma separated.

I hope you found this article helpful.

Until next time, happy CRMing!

Byron Dittberner | Dynamics 365 & Power Platform Solution Architect