Skip to main content
Community site session details

Community site session details

Session Id : Sfmquy99b4QE7N/XskLsQ9
Power Apps - Microsoft Dataverse
Answered

Patch a dependent Choice field with an IF Statement to Dataverse from a Power Apps form

Like (0) ShareShare
ReportReport
Posted on 22 Nov 2023 17:37:36 by 56

Hi all,

 

I would like to patch two fields to Dataverse from a Canvas Apps form.


I have two Choice field Dataverse comboboxes. The first is named 'Team' and is a Choice column that has two options to pick from.

 

The 2nd Choice column has an IF statement on the box in Power Apps and the column is named 'Tasks'. The 2nd column Choices depend upon what team is selected in the first column and selects from two Choice column tables in Dataverse (Management Projects, User Team Projects) using this IF statement:


If(
varChoice = 'Team'.'Management Team',
Choices('Management Projects'),
varChoice = 'Team'.'Users Team',
Choices('User Team Projects')
)
This works great for me.

 

I can patch the first Choice column to Dataverse using

'Team': ComboBox3.Selected.Value

 

with no issues...

 

BUT I cannot patch the 2nd Choice combobox with the two choice columns and the IF. Is there a column type in Dataverse that can accommodate this combobox? I've tried a text column to patch to and a current Choice combobox, with no luck. 

I get the error "The type of this argument does not match the expected type 'OptionSetValue....'. Found type 'Record'.

 

Is there another way to get this to patch to Dataverse? Is there a specific data column type that will allow me to patch this IF Choice combobox to?

 

Thanks a lot in advance.

Categories:
  • eel1 Profile Picture
    56 on 23 Nov 2023 at 19:45:32
    Re: Patch a dependent Choice field with an IF Statement to Dataverse from a Power Apps form

    Hi Static, thank you very much for your reply, i will take a look and try it out and let you know. Thanks again.

  • Verified answer
    Static Profile Picture
    118 on 22 Nov 2023 at 20:01:55
    Re: Patch a dependent Choice field with an IF Statement to Dataverse from a Power Apps form

    Hi @eel1 

    Here are steps that you can take to resolve this issue:

    1. Check the Data Type of the Choice Column: Verify that the data type of your 'Tasks' column in Dataverse is a Choice column (OptionSet). If it's a text column, you may need to change it to a Choice column.

    2. Use OptionSetValues in Your Patch: When patching the 'Tasks' column, make sure you are using the OptionSetValue corresponding to the selected option. You can find these values in the Power Platform or Dataverse settings.

      Assuming 'Tasks' is a Choice column and you want to patch a value for 'Management Projects', you would do something like:

      Patch(
      YourDataverseTableName,
      Defaults(YourDataverseTableName),
      {
      'Tasks': {
      Value: 1
      }
      }
      )

      Replace YourDataverseTableName with the actual name of your Dataverse table.

      3. Use Switch Instead of IF:
       You might find it cleaner to use the Switch function instead of If for your logic. It can make your formula more readable:

      Switch(
      ComboBox3.Selected.Value,
      'Team'.'Management Team', PatchValueForManagementProjects(),
      'Team'.'Users Team', PatchValueForUserTeamProjects(),
      DefaultPatchValue() 

      Then define PatchValueForManagementProjects(), PatchValueForUserTeamProjects(), and DefaultPatchValue() functions to return the correct OptionSetValue based on the selected team.

      This can help you structure your code more clearly and make it easier to troubleshoot.

      If issue repeated, check structure of your table.

     

    Best regards,

    Anton

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Featured topics