cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lburgess
Level: Powered On

Unable to update collection from gallery if current values in collection are null/empty

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????

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Unable to update collection from gallery if current values in collection are null/empty

Hi @lburgess 

You're not missing anything. Unfortunately, there's a bug/limitation in PowerApps that prevents us from updating collections if the source field contains a blank/null. Here's a thread that contains a similar problem.

 

https://powerusers.microsoft.com/t5/General-Discussion/Patch-not-updating-on-null-values-in-database...

 

A workaround for this problem is to replace any blank fields with an empty string. You could use code that looks like this after your ClearCollect:

UpdateIf(collection1, IsBlank(UtilityProviderName), {UtilityProviderName:""})
--> Repeat the above for any possible blank fields that you might want to update

 

View solution in original post

2 REPLIES 2
Super User
Super User

Re: Unable to update collection from gallery if current values in collection are null/empty

Hi @lburgess 

You're not missing anything. Unfortunately, there's a bug/limitation in PowerApps that prevents us from updating collections if the source field contains a blank/null. Here's a thread that contains a similar problem.

 

https://powerusers.microsoft.com/t5/General-Discussion/Patch-not-updating-on-null-values-in-database...

 

A workaround for this problem is to replace any blank fields with an empty string. You could use code that looks like this after your ClearCollect:

UpdateIf(collection1, IsBlank(UtilityProviderName), {UtilityProviderName:""})
--> Repeat the above for any possible blank fields that you might want to update

 

View solution in original post

Highlighted
lburgess
Level: Powered On

Re: Unable to update collection from gallery if current values in collection are null/empty

Thanks!  I found that not long after I posted the question. It does seem to resolve the issue.  At the same time, it seems that should be unnecessary.  Not sure why PowerApps would treat a blank any differently than "" or " ".

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,744)