Search code examples
polymorphismpowerappspowerapps-canvasdataverse

Submit Form based on dataverse table with Polymorphic field owner


I've created a form based on a dataverse table with User/Team ownership.

In such table only 3 fields are required:

  • ID
  • Status
  • Owner

When adding those 3 field to the form I can see values for the first 2, not for the Owner field.

Trying to submit the form (after modifying an existing record) I get a generic failure message.

An entry is required or has an invalid value. Please correct and try again

I have the suspect that the form doesn't provide data for updating the Owner field, and this led me to study those Polymorphic fields.

After reading this, that and another post, I understood how to show the Owner of this field in the form datacard (although this was not my goal). But I'm still having problem updating that field.

so my question is, if a record already has an owner, do I still need to Update it? how can I do that? do I need to use Patch or can I write it in the Update property to make it work along with SubmitForm(...)?

In this case for me the owner should be automatically picked up based on User().Email.

Bonus question, when creating a new record in this table, will I also have to generate the ID or dataverse will still take care of it? on the same topic, will I have to figure out how to provide an "Active" value for the Status field too?

Thank you in advance for any help!


Solution

  • I found the solution in the end, sharing here should anybody need it in the future:

    You don't need to update the field, if not included in the loaded fields of the form, Dataverse in the background will take care of adding owner, status, and the ID (if properly set on Dataverse side). So simply exclude those fields from the form and the system will take care of them.

    But at first I didn't have those fields and yet could not save the form.

    It was in the end because of another field, a lookup field that describes the relationship with another table. Once I took care of filling out that field automatically in the background (not visible data-card), it worked properly, but those 3 fields were still included, hence the error that I was encountering.

    This also answer to my "bonus question", yes, PowerApps and Dataverse take care of filling out those fields also when creating a new item.