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

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
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (10,493)