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.
Hi Static, thank you very much for your reply, i will take a look and try it out and let you know. Thanks again.
Hi @eel1
Here are steps that you can take to resolve this issue:
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.
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(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:
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