cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Patch inserts unwanted NULL values

Hi,

I'm having a non-consistent issue with my Powerapp. A Patch function that I'm running doesn't always get all of its parameters correctly. The values that fail are ones that are read directly from datacard values (input fields). To me it seems as if the value simply is not read, at therefore the Patch ends up sending NULL and 0 values.
I haven't been able to come up with a way of checking to see if the datacard values are NULL (I'm aware of Blank, Coalesce, IsBlank, and IsEmpty), since the only option is to set up and IF that just tries again once, which most likely won't be enough to it right each time.

I've tried getting around the issue by creating a loop (but this is not possible in PA). I also tried using this method: https://blog.coeo.com/powerapps-blog-series-recursion-using-a-numbers-table , by running a Patch within a ForAll on a collection with 30 entries, but to no avail.

Extra info: Its a relatively simple Patch directed at a SQL database. All the other values read are always added correctly. The reason I'm using Patch is because I'm already submitting the data to another table, but the solution I'm working needs two different tables to be updated. And once again, it is not happening every time, so to me it feels like a connection/network issue, or maybe just PA being unstable?

//PNman

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Patch inserts unwanted NULL values

Hi @PNman 

It might be useful for us to see the code, and to see the place where you're calling Patch.

This could be a timing problem, which could explain the intermittent nature of the problem.

For example, if you have a form that submits your changes to TableA and a Patch function that runs afterwards to create a record in TableB, it could be the case that following the call to SubmitForm, PowerApps will reset the controls on the form. So if you call Patch afterwards, it'll pickup the reset values, which would result in you seeing those NULL and 0 values.

I would try to save the values that you want to Patch into a variable before you call SubmitForm, and to use those variables in your call to Patch. Hopefully, that might take you a bit further.

 

 

View solution in original post

9 REPLIES 9
Highlighted
Advocate IV
Advocate IV

Re: Patch inserts unwanted NULL values

Just brainstorming, but could it be that the value didn't change and because of that it's somehow empty?

 

Does the same happen if you Patch using the 'Updates' property of your EditForm?

Highlighted
Helper I
Helper I

Re: Patch inserts unwanted NULL values

Hi @MrNappa ,

That does look interesting, but I can't seem to find the 'Updates' property of my editform. Is this a new thing? Or is it reffering to the 'Update' on the individual datacards?

//PNman

Highlighted
Advocate IV
Advocate IV

Re: Patch inserts unwanted NULL values

I'm not sure if Updates is new, I haven't been using Powerapps for that long. And it should be available on an EditForm, I linked to the docs in my previous post (there's no anchor link to the 'updates' propery though so you have to scroll to it). It's just not available in the properties dropdown of the control, as it's an output parameter only.

Highlighted
Helper I
Helper I

Re: Patch inserts unwanted NULL values

Hmm.. I don't think that's how 'Updates' work: https://youtu.be/N8DWvS7P9lw?t=740 It seems more related to what the data that was submitted was. I guess I could use it to check if the submitted data was correct, but since I can't create a loop or anything similar, it would be impossible to make sure that the value I replaced the 'NULL' with was correct.

//PNman

Highlighted
Advocate IV
Advocate IV

Re: Patch inserts unwanted NULL values

Here's another idea for debugging the values for NULL: add a 'Toggle' input on the screen somewhere for each value you want to check, and set the Default property of each to a null check of the value(s) you're trying to patch.

Highlighted
Helper I
Helper I

Re: Patch inserts unwanted NULL values

I can easily see the value of the input fields, and therefore I can see that they are properly filled out. I don't understand what setting up these toggles would change. I think the issues happens somewhere "between" the Patch reading the values and the inputs being read.

Thanks for the input though, it is much appreciated.

//PNman

Highlighted
Super User
Super User

Re: Patch inserts unwanted NULL values

Hi @PNman 

It might be useful for us to see the code, and to see the place where you're calling Patch.

This could be a timing problem, which could explain the intermittent nature of the problem.

For example, if you have a form that submits your changes to TableA and a Patch function that runs afterwards to create a record in TableB, it could be the case that following the call to SubmitForm, PowerApps will reset the controls on the form. So if you call Patch afterwards, it'll pickup the reset values, which would result in you seeing those NULL and 0 values.

I would try to save the values that you want to Patch into a variable before you call SubmitForm, and to use those variables in your call to Patch. Hopefully, that might take you a bit further.

 

 

View solution in original post

Highlighted
Helper I
Helper I

Re: Patch inserts unwanted NULL values

Saving the values in variables before the submit at then using said variables fixed it. Thanks!

//PNman

Highlighted
Super User
Super User

Re: Patch inserts unwanted NULL values

You're welcome, glad that solved the problem!

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 (7,396)