In this Power Apps Dataverse tutorial, We will discuss how to work with Power Apps Patch Dataverse Choice Column. Additionally, we will see how to patch Datavarse Text, Number, and Date columns in Power Apps Edit Form Control.
Furthermore, we will get to know how to update Dataverse Choice Column (Single-choice value) in Power Apps and how to update Dataverse Choice Column (Multi-choice value) in Power Apps.
On a recent project, I had to patch the Dataverse Choice values (multiple choice option set) in a Power Apps Edit form. Once the user will submit the Choice values, then those choices will be stored in the relevant Dataverse table.
So let’s get started with this.
Also, Read: How to Display Dataverse Choices in Power Apps Gallery
Power Apps Patch Dataverse Choice Column
Here we will see how to Patch Dataverse Choice Column in Power Apps.
The below screenshot represents a Dataverse table named Patient Registrations. In this table, there are various columns with various data types. Such as:
- Patient Name = This is a Primary column having with Single line of text data type.
- DOB = Date Data type
- Age = Whole Number Data type
- Address = Multi-line of text Data type
Along with these columns, there is one more column called Reason with Choice Data type (including multi-selection option set).
The below image represents all the Dataverse choices like High Blood Pressure, Diabetes, Heart Issues, etc. Whereas, Patient Disease Reason is the Choice Display Name.
Now, I would like to patch the Dataverse choice values in a Power Apps Edit Form control.
Example:
- In Power Apps, there is a Power Apps Edit form with all the Dataverse table columns like Patient Name, Patient Phone Number, DOB, Reason, etc.
- Also, there is a Power Apps Button control (REGISTER) that helps to store the form entries in the Dataverse table.
- But before that, make sure you need to connect the Dataverse Connector and choose the Dataverse table (Patient Registrations) to Power Apps. Otherwise, you may get some errors.
- You can connect the Dataverse connector by using the Data tab (from the left navigation).
- Next, to patch the Dataverse Choice values as well as other data values, apply the code below on the Button’s OnSelect property as:
OnSelect = Patch(
'Patient Registrations',
Defaults('Patient Registrations'),
{
'Patient Name': DataCardValue1.Text,
'Patient Phone Number': DataCardValue6.Text,
DOB: DateValue1.SelectedDate,
Age: Value(DataCardValue3.Text),
Address: DataCardValue4.Text,
Reason: DataCardValue5.SelectedItems
}
)
Where,
- Patch = Power Apps Patch Function is used to create a new record or modify single or multiple records in a data source.
- ‘Patient Registrations’ = Provide Dataverse Table name
- ‘Patient Name’, ‘Patient Phone Number’, and so on = These are the Dataverse Column names
- DataCardValue1 = This is the Data card value of Patient name
- DataCardValue6 = This is the Data card value of Patient Phone Number
- DateValue1 = Data card value of DOB
- DataCardValue3 = Data card value of Age
- DataCardValue4 = Data card value of Address
- Reason = Specify the Dataverse Choice Column Name (multi-choice option set)
- DataCardValue5.SelectedItems = This is a Combobox control since this Dataverse choice column has a Multi-choice option configured. You need to specify the Dataverse choice column data card value including the SelectedItems property as shown below.
- Finally, Save and Publish the app. Preview the app and provide all the patient details including the choice values (multi-choice). Click on the REGISTER button.
- Next, go to the specific Dataverse Table (Patient Registrations) and refresh that table once. You can see the new entry has been added to the Dataverse table including the multi-choice options as below.
This is how to Patch Dataverse Choice Column (multi-choice option set) in Power Apps.
Check out: Power Apps Get Value Of Choice Field Dataverse
Update Dataverse Choice Column in Power Apps
In this section, We will see how to update the Dataverse Choice column (Single Choice Value) in Power Apps.
- Here also, I have taken the same above Dataverse Table (Patient Registrations). In that table, I have created a new Choice column (Marital Status) with a single choice value. That means, the user can select only one choice option at a time.
- The below screenshot refers to all the Dataverse choice options (like Married, Single, Divorced, Widowed) i.e. available inside the Marital Status field.
- Using Power Apps, I now would like to update Christiana’s Marital Status, the first patient in the Dataverse table (Patient Registrations).
- To work around this, insert a Power Apps Button control and rename it to Click & Update Marital Status. Select the button and set its OnSelect property to the code below:
OnSelect = Patch(
'Patient Registrations',
First(
Filter(
'Patient Registrations',
'Patient Name' = "Christiana"
)
),
{'Marital Status': 'Select Marital Status '.Married}
)
Where,
- ‘Patient Registrations’ = Provide the Dataverse table name
- ‘Patient Name’ = Specify the primary column column
- “Christiana” = Provide the specific column value of whom you want to update the choice value. You need to specify the value including an inverted comma (” “).
- ‘Marital Status’ = This is the Dataverse Choice Column Name
- ‘Select Marital Status ‘ = Specify the Dataverse Choice Display Name
- Married = Provide the Choice value that you want to update
Refer to the screenshot below.
- Finally, Save and Publish the app. Preview the app and then tap on the button (Click & Update Marital Status). Then, go to the Dataverse table (Patient Registrations) and refresh it.
- You can see the marital status of the first record (Christiana) has been updated to Married as shown in the screenshot below.
This is how to update Dataverse Choice Column in Power Apps.
Have a look: How to filter SharePoint choice field within Power Apps?
Update Dataverse Choices in Power Apps
Here, we will see how to update Dataverse Choices (multi-choice option set) in Power Apps.
- In Power Apps, there is a Button control named Click & Update Patient Disease Reason. When the user will click on the button, then the specific Choice field value (Reason) will update.
- In the below screenshot, you can see Reason is my Dataverse Choice column with a multi-choice option set. That means the user can select multiple choices at a time.
- Now I would like to update the Reason for the fourth patient i.e. Patriot. Refer to the instructions below that how we can achieve it in Power Apps.
- In Power Apps, select the Button control (Click & Update Patient Disease Reason) and apply the code below on its OnSelect property as:
OnSelect = Patch(
'Patient Registrations',
First(
Filter(
'Patient Registrations',
'Patient Name' = "Patriot"
)
),
{
Reason: [
'Patient Disease Reason'.Diabetes,
'Patient Disease Reason'.Fever
]
}
)
Where,
- ‘Patient Registrations’ = Provide the Dataverse table name
- ‘Patient Name’ = Specify the primary column column
- “Patriot” = Provide the specific column value of whom you want to update the choice value. You need to specify the value including an inverted comma (” “).
- Reason = Specify the Dataverse Choice Column Name (multi-choice option set)
- ‘Patient Disease Reason’ = Specify the Dataverse Choice Display Name (multi-choice option set)
- Diabetes, Fever = Specify the Choice values that you want to update
Refer to the screenshot below.
- Finally, Save and Publish the app. Preview the app and then tap on the button (Click & Update Patient Disease Reason). Then, go to the Dataverse table (Patient Registrations) and refresh it.
- You can see the Reason for the first record (Patriot) has been updated to Diabetes, Cold as shown in the below screenshot.
This is how to update Dataverse Choices (multi-choice option set) in Power Apps.
Furthermore, you may like some more Dataverse and Power Apps tutorials:
- How to Patch Dataverse Number Field in Power Apps
- Power Automate Dataverse Update Multiple Rows
- How to Highlight the Selected Item within a Power Apps Gallery?
- How to Detect Text in Dataverse Using AI Builder
- PowerApps multi-select dropdown
- How to calculate sum of gallery items in Power Apps?
- Create a Power Apps dialog box or Popup message box
- Microsoft Flow Error “Could not find a property named ‘crf9a_Sender’ on type“
In this Power Apps Dataverse tutorial, We discussed how to work with Power Apps Patch Dataverse Choice Column. Additionally, we saw how to patch Datavarse Text, Number, and Date columns in Power Apps Edit Form Control.
Furthermore, we got to know how to update Dataverse Choice Column (Single-choice value) in Power Apps and how to update Dataverse Choice Column (Multi-choice value) in Power Apps.
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.
Very good post, Thank you.
I’ve use a gallery instaed of dropdown to update my choices field, it works well.