cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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
Highlighted
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
Highlighted
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
Frequent Visitor

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
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,930)