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
Solved! Go to Solution.
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:
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
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.
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:
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
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.
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)
}
)));
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!
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
203 | |
179 | |
67 | |
36 | |
33 |
User | Count |
---|---|
341 | |
271 | |
113 | |
74 | |
58 |