cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Patron
Post Patron

PowerApps Doesn't update numeric Values in a collection via Patch statement

The following patch statement does not update an integer column in a collection:

 

ForAll(RenameColumns(vRecommendationRowId,"Recommendation_ID", "vRecommendation_ID"),
    Patch(Recommendation, First(Filter(Recommendation, New_Recommendation_ID=vRecommendation_ID)),
          {
              RowId: Value(vRecommendation_ID),
              TempInt:   Value("2") ,
              ActualRowId: Value(888),
              UserId: "ABC"
          }
));

 

I have tried theTempInt: 2, TempInt Value("2"), etc. without luck.

 

Any ideas ?

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: PowerApps Doesn't update numeric Values in a collection via Patch statement

Hi @vsslasd,

Does the TempInt column (Number column) have values within it already in your Recommendation collection?

The user @ChadVKealey has faced similar issue with you, please check my response within the following thread:

https://powerusers.microsoft.com/t5/Expressions-and-Formulas/Patch-Problem-Existing-data-updated-new...

Currently, when updating a column value within a Collection using Patch function, the Patch function could only update the column which has value within it already, it could not update a column with a null or empty value within it.

As an fixed solution, please consider take a try to turn on/enable the "Formula-level error management" option within the Advanced settings of App settings of your app, then re-load your app, try your formula again, check if the issue is solved.

In addition, as alternative solution, you could also consider take a try to update your Collection using UpdateIf function rather than Patch function. Please take a try to modify your formula as below:

ForAll(
RenameColumns(vRecommendationRowId,"Recommendation_ID", "vRecommendation_ID"), UpdateIf(
Recommendation,
New_Recommendation_ID = vRecommendation_ID, { RowId: Value(vRecommendation_ID), TempInt: Value("2") , ActualRowId: Value(888), UserId: "ABC" } )
)

Please take a try with above UpdateIf function, then check if the issue is solved.

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Highlighted
Resolver I
Resolver I

Re: PowerApps Doesn't update numeric Values in a collection via Patch statement

Hi @vsslasd,

 

Do you wan to Patch the value to Recommendation.Columns when New_Recommendation_ID=vRecommendation_ID?

And vRecommendation_ID is one column in vRecommendationRowId which is replace the Recommendation_ID?

 

I tested as this and it works ok. And TempInt : Value(2) also works fine.

 

Step1: add the button named:Button_Recommendation and set its Onselect:

ClearCollect(Recommendation,{New_Recommendation_ID:"1", RowId:"1",TempInt:"1",ActualRowId:"1",UserId:"1"},{New_Recommendation_ID:"2", RowId:"1",TempInt:"1",ActualRowId:"1",UserId:"1"})

 

Step2:add the button named:Button_vRecommendationRowId and set its Onselect:ClearCollect(vRecommendationRowId,{Recommendation_ID:"1"},{Recommendation_ID:"2"},{Recommendation_ID:"3"})

 

Step3: insert one datatable and set its items:Recommendation

 

Step4:insert one button and set its Onselect:

ForAll(RenameColumns(vRecommendationRowId,"Recommendation_ID", "vRecommendation_ID"),

   Patch(Recommendation, First(Filter(Recommendation, New_Recommendation_ID=vRecommendation_ID)),

         {

             RowId: Value(vRecommendation_ID),

             TempInt:   Value("2") ,

             ActualRowId: Value(888),

             UserId: "ABC"

         }

))

 Hope this can be helpful.

test_PowerApps Doesn't update numeric Values in a collection via Patch statement1.gif

Highlighted
Community Support
Community Support

Re: PowerApps Doesn't update numeric Values in a collection via Patch statement

Hi @vsslasd,

Does the TempInt column (Number column) have values within it already in your Recommendation collection?

The user @ChadVKealey has faced similar issue with you, please check my response within the following thread:

https://powerusers.microsoft.com/t5/Expressions-and-Formulas/Patch-Problem-Existing-data-updated-new...

Currently, when updating a column value within a Collection using Patch function, the Patch function could only update the column which has value within it already, it could not update a column with a null or empty value within it.

As an fixed solution, please consider take a try to turn on/enable the "Formula-level error management" option within the Advanced settings of App settings of your app, then re-load your app, try your formula again, check if the issue is solved.

In addition, as alternative solution, you could also consider take a try to update your Collection using UpdateIf function rather than Patch function. Please take a try to modify your formula as below:

ForAll(
RenameColumns(vRecommendationRowId,"Recommendation_ID", "vRecommendation_ID"), UpdateIf(
Recommendation,
New_Recommendation_ID = vRecommendation_ID, { RowId: Value(vRecommendation_ID), TempInt: Value("2") , ActualRowId: Value(888), UserId: "ABC" } )
)

Please take a try with above UpdateIf function, then check if the issue is solved.

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Resolver I
Resolver I

Re: PowerApps Doesn't update numeric Values in a collection via Patch statement

Hi @v-xida-msft,

 

Yes. You are right and I have tested  if there is none in the collection and will not Patch data into it.

This maybe the cause.Many thanks.

 

 

Highlighted
Post Patron
Post Patron

Re: PowerApps Doesn't update numeric Values in a collection via Patch statement

Kris,

So very many thanks for your assistance. This was a tricky issue. 

 

Your UpdateIf was a huge help, and that worked. We had to also rename columns yet again. PowerApps is very finicky about columns with the same name in different collections/sources.

 

This is the code that works:

If(Connection.Connected, 
ForAll(RenameColumns(vRecommendationRowId, "Recommendation_ID", "vRecommendation_ID","RowId","RID"),
    UpdateIf(
        Recommendation,
         New_Recommendation_ID = vRecommendation_ID,
          {
              RowId: Value(RID)
          }
)));

Post Patron
Post Patron

Re: PowerApps Doesn't update numeric Values in a collection via Patch statement

Thank you, Kris. 

Is this a bug which you are reporting to Microsoft to resolve? 

I was able to get this to work using an UpdateIf for the Collection. But it will be a problem when we Patch to SQL Server using the same scenario (unless an UpdateIf can be used on a SQL Server table, but I don't think it can, it can only be a Patch Statement).

 

Thank you so very much, you have a big a great help with this!

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,439)