web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch a dependent Choi...
Power Apps
Unanswered

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

(0) ShareShare
ReportReport
Posted on 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.

I have the same question (0)
  • Verified answer
    Static Profile Picture
    118 on at

    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

  • eel1 Profile Picture
    56 on at

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

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 793 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard