How to Patch Dataverse Choice Column in Power Apps

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:

  1. Patient Name = This is a Primary column having with Single line of text data type.
  2. DOB = Date Data type
  3. Age = Whole Number Data type
  4. 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).

Power Apps Patch Dataverse Choice Column
Power Apps Patch Dataverse Choice Column

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.

Patch Dataverse Choice Column PowerApps
Patch Dataverse Choice Column PowerApps

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.
How to Patch Dataverse Choice Column in Power Apps
How to Patch Dataverse Choice Column in Power Apps
  • 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).
Patch Dataverse Choice Column in Power Apps
Patch Dataverse Choice Column in Power Apps
  • 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,

  1. Patch = Power Apps Patch Function is used to create a new record or modify single or multiple records in a data source.
  2. ‘Patient Registrations’ = Provide Dataverse Table name
  3. ‘Patient Name’, ‘Patient Phone Number’, and so on = These are the Dataverse Column names
  4. DataCardValue1 = This is the Data card value of Patient name
  5. DataCardValue6 = This is the Data card value of Patient Phone Number
  6. DateValue1 = Data card value of DOB
  7. DataCardValue3 = Data card value of Age
  8. DataCardValue4 = Data card value of Address
  9. Reason = Specify the Dataverse Choice Column Name (multi-choice option set)
  10. 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.
PowerApps Patch Dataverse Choice Column
PowerApps Patch Dataverse Choice Column
  • 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.
Patch Dataverse Choice Column Power Apps
Patch Dataverse Choice Column Power Apps
  • 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.
How to Patch Dataverse Choice Columns in Power Apps
How to Patch Dataverse Choice Columns in Power Apps

This is how to Patch Dataverse Choice Column (multi-choice option set) in Power Apps.

See also  Power BI Waterfall Chart - Detailed Guide

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.
Update Dataverse Choice Column in Power Apps
Update Dataverse Choice Column in Power Apps
  • Using Power Apps, I now would like to update Christiana’s Marital Status, the first patient in the Dataverse table (Patient Registrations).
How to update Dataverse Choice Column in Power Apps
How to update Dataverse Choice Column in Power Apps
  • 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,

  1. ‘Patient Registrations’ = Provide the Dataverse table name
  2. ‘Patient Name’ = Specify the primary column column
  3. “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 (” “).
  4. ‘Marital Status’ = This is the Dataverse Choice Column Name
  5. ‘Select Marital Status ‘ = Specify the Dataverse Choice Display Name
  6. Married = Provide the Choice value that you want to update

Refer to the screenshot below.

Power Apps Update Dataverse Choice Column
Power Apps Update Dataverse Choice Column
  • 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.
How to update Dataverse Choice Value in Power Apps
How to update Dataverse Choice Value in Power Apps

This is how to update Dataverse Choice Column in Power Apps.

See also  Power Automate delete file from SharePoint

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.
Update Dataverse Choices in Power Apps
Update Dataverse Choices in Power Apps
  • 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.
Update Dataverse Choices in PowerApps
Update Dataverse Choices in PowerApps
  • 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,

  1. ‘Patient Registrations’ = Provide the Dataverse table name
  2. ‘Patient Name’ = Specify the primary column column
  3. “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 (” “).
  4. Reason = Specify the Dataverse Choice Column Name (multi-choice option set)
  5. ‘Patient Disease Reason’ = Specify the Dataverse Choice Display Name (multi-choice option set)
  6. Diabetes, Fever = Specify the Choice values that you want to update

Refer to the screenshot below.

How to update Dataverse Choices in Power Apps
How to update Dataverse Choices in Power Apps
  • 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.
Power Apps Update Dataverse Choices
Power Apps Update Dataverse Choices

This is how to update Dataverse Choices (multi-choice option set) in Power Apps.

See also  Power BI Pie Chart Drill Down

Furthermore, you may like some more Dataverse and Power Apps tutorials:

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.

  • >