I have a SharePoint list that I want to load into a gallery, then allow the user to edit the details of each row and save the results back to the list. Fairly straightforward stuff.
I know that for each row in the parent list there will always be 4 rows in the child list (the list used to populate the gallery). Furthermore I know basically what those rows will look like. The app is related to leases. This particular screen contains information regarding the utilities (power, water, gas, and sewer) associated with the lease. When I initially create the rows in the utility list for a given lease, I seed them with the type of utility and set the other values to Blank().
On a subsequent page I load the utilities gallery from the utility list for editing. Here’s where things get strange.
If I load the rows directly from the list into a collection (the preferred method, I would assume) using the following:
ClearCollect(
colUtilities,
Filter(
'Branch Location Utilities',
BranchLocationInformationID = gblID <-- the ID from the parent row
)
);
the rows load successfully. However, when I try to edit the rows in the gallery and update the collection on change with this code
Patch(colUtilities,
ThisItem,
{UtilityProviderName: txtProviderName_Utilities.Text}
);
the collection does not update unless there is already a non-blank value in the column.
However, if instead of the ClearCollect above I do this:
Clear(colUtilities);
Patch(
colUtilities,
Defaults(colUtilities),
{
Title: gblTitle,
UtilityType: "Power",
UtilityResponsibility: "IMS",
UtilityProviderName: "",
UtilityProviderContact: "",
UtilityProviderPhone: "",
UtilityProviderWebAddress: "",
UtilityProviderContactEmail: "",
UtilityProviderNotes: "",
UtilityDepositRequired: "TBD",
UtilityDepositAmount: 0
}
);
four times (once for each utility type) and try to edit the rows in the gallery and update the collection on change with the same Patch statement as above, the collection updates correctly.
Obviously neither solution is acceptable. I can’t use the first scenario because it makes no sense to load non-blank values for the columns. If I use the second scenario, I’m not loading the collection with the existing values from the list.
What am I missing????