
I previously had a question on Lookups in Forms that @RandyHayes helped me with, but this one is more complex (or at least I am making it so in my head!)
I'm building a Power App in Teams, with Dataverse for Teams as my datasource. I'm struggling to get some of my fields to prepopulate properly in edit forms
I have a "Requests" table which has a lookup column, Request Type
In the Request Types table, I have the "Identifier" which is the lookup column, and 3 additional columns: Category, Type and Sub-type
In my form I have 3 custom fields with cascading Combo Boxes for "Category", "Type" and "Sub-type". My "Request Types" field will be a hidden field that populates based on the selections in Category, Type and Sub-type.
My problem: When I view an existing record, the comoboxes correctly show the correct Category, Type and Sub-type as expected (although strangely they are faded as if they are disabled fields… that's future Sandie's problem) however, when I go into Edit mode the fields are blank.
View Mode:
Edit Mode:
When I select the correct Category (in this case Website), the Type, Sub-type and Request Type suddenly fill to the correct selections as well.
I understand that the Type, Sub-Type and Request Type are not initially populated because they are dependent on Category being populate, but why is my "Category" not showing the correct default selection in Edit mode?
For reference:
| Items | DefaultSelectedItems |
Category | Distinct('Request Types',Category) | {Result: LookUp('Request Types',Identifier=ThisItem.'Request Type'.Identifier).Category} |
Type | Distinct(Filter('Request Types',Category = re_RequestCategoryValue.Selected.Result),Type) | {Result: LookUp('Request Types',Identifier=ThisItem.'Request Type'.Identifier).Type} |
Sub-type | Distinct(Filter('Request Types',Type = re_RequestTypeValue.Selected.Result),'Sub-type') | {Result: LookUp('Request Types',Identifier=ThisItem.'Request Type'.Identifier).'Sub-type'} |
Request Type | Choices([@Requests].'Request Type') | First(Filter('Request Types',Category = re_RequestCategoryValue.Selected.Result, Type = re_RequestTypeValue.Selected.Result, 'Sub-type' = re_RequestSubTypeValue.Selected.Result)) |
Note: with my DefaultSelectedItems I had thought that I could just put eg: ThisItem.'Request Type'.Category, however this did not work. Although it does not error, the output is blank when tested in a Label. I can get the exact lookup field: ThisItem.'Request Type'.Identifier, but not the other Request Type fields.
Note: the Orange text in the combobox datacards is a label where the value is eg: LookUp('Request Types',Identifier=ThisItem.'Request Type'.Identifier).Category, to show that the result/output of the lookup is not blank.