Single Line of Text to Drop-Down in Model Driven Power Apps
In this #PowerShot, I will show you how to use a PCF control to enhance a Single Line of Text (SLT) type column and display it as a Drop-Down of values in Model Driven Power Apps.
Let's Get Started
The scenario for which we are building this setup is where the data type of a column in a Dataverse table is set as Single Line of Text but the data is of type choices and the data type cannot be changed.
This could be a use case where you are working with Virtual Tables and the data type of columns cannot be changed on the target data source. As the column data type cannot be changed, we can use the SLT-Drop-Down PCF control on a Model Driven Power Apps form and restrict the user to only select configured options as an input to the column. Setting this up is comparatively easier when working with Canvas Power Apps. However, at the moment, customizing it directly on a Model Driven Power Apps form is not doable out of the box. Hence, we will use a PCF control to achieve the desired capability.
If you want to start creating a PCF control from scratch, you can start here.
The SLT-Drop-Down PCF control that we are using in this blog post can be found here. You can directly either clone the repository or download the managed solution file and upload it in your environment.
Below is a sample Dataverse table schema. I have added a column named Employee Type of data-type Single Line of Text to the Employee table.
Model Driven App Form
Below is the Model Driven Power Apps form without the PCF control
Below are the steps to add the PCF control and configure options on the Model Driven Power Apps form
1. Navigate to the solution where you have created the Table and then click on the table to open the properties page.
2. Click on the Forms option under Data Experiences as shown below.
3. Open the main form in edit mode where the Single Line of Text field is displayed.
4. Click on the icon  and then click on Get more components as shown in the screenshot below.
5. Select the control and then click on Add as shown in the screenshot below.
6. Once the control is added, select the field on the form. After selecting the form, scroll to the bottom in the right nav bar and click on the +Component button and then select the control from the popup as shown in the image below.
7. Once the component is selected, a pop up appears where you can configure it. Provide the values that have to be displayed in the dropdown separated by a semi colon (;) [you can also bind it to a field on the form to make it more dynamic] and select the platforms where you want the control to appear and click Done and then click Save and Publish shown in the screenshot below.
Note: Ensure that the parameter value is not ending with semi-colon(;) or else a blank value will be added in the dropdown.
Setup in Action
In this post, we saw how to use the SLT-Drop-Down PCF control to display a Single Line of Text type field as a drop down on a Model Driven Power Apps form. This is quite handy when you are working with virtual tables and scenarios where the data type of the column cannot be changed but the data consistency is a priority for the specific column.
Note: This control also supports Whole Number type field.
I hope you found this interesting and it helped you. Thank you for reading!