cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gumgih
Helper II
Helper II

UpdateIf updating values for all records instead of filter one

Hi,

 

Can anyone please help with my issue, I'm filtering the items from the First collection named "CurrentUserCommitGroupDataCollection", and if there are any pending items I want to update the SignOff Status to false for that commit group only in another collection named "SignOffCommitGroupStatusData", but it is updating the SignOff Status for all the existing items in "SignOffCommitGroupStatusData" collection.


help.PNG
Below code, I'm using for the same.

 

If(CountRows(
Filter(
CurrentUserCommitGroupDataCollection,
CommitGroupID = ThisRecord.CommitGroupID && ThisRecord.PedingRiskItemCount > 0
)
) > 0,Filter(
UpdateIf(
SignOffCommitGroupStatusData,
(IsFinalSignOff = true),
{
SignOffByUserID: CurrentUserID,
IsFinalSignOff: false,
IsSignOff: false
}
),
!(IsFinalSignOff = true)
)
)

Can anyone please help?

Thanks!
Mayank 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @gumgih ,

 

I did a test for you, and It worked. Please check if the steps below are different from yours.

 

1\ This is my collection 'CurrentUserCommitGroupDataCollection'

ClearCollect(CurrentUserCommitGroupDataCollection,{CommitGroupID:1,PedingRiskItemCount:0,CurrentUserID:"Test1"},{CommitGroupID:2,PedingRiskItemCount:0,CurrentUserID:"Test2"},{CommitGroupID:3,PedingRiskItemCount:1,CurrentUserID:"Test3"},{CommitGroupID:4,PedingRiskItemCount:1,CurrentUserID:"Test4"})

v-xiaochen-msft_0-1612490505086.png

 

2\ This is my collection 'SignOffCommitGroupStatusData'

ClearCollect(SignOffCommitGroupStatusData,{CommitGroupID:1,IsFinalSignOff:true,IsSignOff:true,SignOffByUserID:"Test5"},{CommitGroupID:2,IsFinalSignOff:true,IsSignOff:true,SignOffByUserID:"Test6"},{CommitGroupID:3,IsFinalSignOff:true,IsSignOff:true,SignOffByUserID:"Test7"},{CommitGroupID:4,IsFinalSignOff:true,IsSignOff:true,SignOffByUserID:"Test8"})

v-xiaochen-msft_1-1612490579814.png

 

3\ Add a button control and set its onselect property to:

ForAll(CurrentUserCommitGroupDataCollection,If(PedingRiskItemCount>0,UpdateIf(SignOffCommitGroupStatusData,SignOffCommitGroupStatusData[@CommitGroupID]=CurrentUserCommitGroupDataCollection[@CommitGroupID],{IsFinalSignOff:false,SignOffByUserID: CurrentUserID,IsSignOff: false})));Set(Collection_SignOffPayLoad, Filter(SignOffCommitGroupStatusData,!(IsFinalSignOff=true)))

 

4\ After I press the button, the modified collection 'SignOffCommitGroupStatusData' is:

191.PNG

 

5\ At this point, the value of the variable Collection_SignOffPayLoad is:

192.PNG

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

 

View solution in original post

8 REPLIES 8
v-xiaochen-msft
Community Support
Community Support

Hi @gumgih ,

 

In your formula, you use the updateif() function to change the value of the IsFinalSignOff column to false. Then you use the filter() function to lookup the records where the value of the IsFinalSignOff column is false.

At this time, what you get is all the records in the collection, because the value of the IsFinalSignOff column of all your records is false.

 

Therefore, the key is which records in the "SignOffCommitGroupStatusData" collection you want to update.

I think it depends on the "CurrentUserCommitGroupDataCollection" collection.

Please tell me more information. For example, the conditions of using updateif() function, the relationship between two collections, etc.

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

@v-xiaochen-msft thanks for your response.

 

actually i just want to lookup the records from "CurrentUserCommitGroupDataCollection" where PedingRiskItemCount > 0, and update IsSignOff and IsFinalSignOff values to False for that perticular record in "SignOffCommitGroupStatusData" collection not for others.
Let me know if you need more information.

help1.PNG

v-xiaochen-msft
Community Support
Community Support

Hi @gumgih ,

 

If I find a record in the "CurrentUserCommitGroupDataCollection" collection, how can I find the related record in the "SignOffCommitGroupStatusData" collection?

If I know this, the problem can be solved with the Forall() function.

 

Best Regards,

Wearsky

@v-xiaochen-msft sorry i missed the key column to mention.

 

The key between both collections is "CommitGroupID".

 

help2.PNG

v-xiaochen-msft
Community Support
Community Support

Hi @gumgih ,

 

Please try this formula:

ForAll(CurrentUserCommitGroupDataCollection,If(PedingRiskItemCount>0,UpdateIf(SignOffCommitGroupStatusData,SignOffCommitGroupStatusData[@CommitGroupID]=CurrentUserCommitGroupDataCollection[@CommitGroupID],{IsFinalSignOff:false,SignOffByUserID: CurrentUserID,IsSignOff: false})));Set(Collection_SignOffPayLoad, Filter(SignOffCommitGroupStatusData,!(IsFinalSignOff=true)))

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

@v-xiaochen-msft, unfortunately, it is not updating any Fields 😞 .

 

Eventhough i have one pending item in "CurrentUserCommitGroupDataCollection", but still "IsSignOff" and "IsFinalSignOff" are coming as true in "SignOffCommitGroupStatusData".

help4.PNGhelp5.PNG

v-xiaochen-msft
Community Support
Community Support

Hi @gumgih ,

 

I did a test for you, and It worked. Please check if the steps below are different from yours.

 

1\ This is my collection 'CurrentUserCommitGroupDataCollection'

ClearCollect(CurrentUserCommitGroupDataCollection,{CommitGroupID:1,PedingRiskItemCount:0,CurrentUserID:"Test1"},{CommitGroupID:2,PedingRiskItemCount:0,CurrentUserID:"Test2"},{CommitGroupID:3,PedingRiskItemCount:1,CurrentUserID:"Test3"},{CommitGroupID:4,PedingRiskItemCount:1,CurrentUserID:"Test4"})

v-xiaochen-msft_0-1612490505086.png

 

2\ This is my collection 'SignOffCommitGroupStatusData'

ClearCollect(SignOffCommitGroupStatusData,{CommitGroupID:1,IsFinalSignOff:true,IsSignOff:true,SignOffByUserID:"Test5"},{CommitGroupID:2,IsFinalSignOff:true,IsSignOff:true,SignOffByUserID:"Test6"},{CommitGroupID:3,IsFinalSignOff:true,IsSignOff:true,SignOffByUserID:"Test7"},{CommitGroupID:4,IsFinalSignOff:true,IsSignOff:true,SignOffByUserID:"Test8"})

v-xiaochen-msft_1-1612490579814.png

 

3\ Add a button control and set its onselect property to:

ForAll(CurrentUserCommitGroupDataCollection,If(PedingRiskItemCount>0,UpdateIf(SignOffCommitGroupStatusData,SignOffCommitGroupStatusData[@CommitGroupID]=CurrentUserCommitGroupDataCollection[@CommitGroupID],{IsFinalSignOff:false,SignOffByUserID: CurrentUserID,IsSignOff: false})));Set(Collection_SignOffPayLoad, Filter(SignOffCommitGroupStatusData,!(IsFinalSignOff=true)))

 

4\ After I press the button, the modified collection 'SignOffCommitGroupStatusData' is:

191.PNG

 

5\ At this point, the value of the variable Collection_SignOffPayLoad is:

192.PNG

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

 

@v-xiaochen-msft Thank you so much, It Works! there was some other code that is creating issues earlier now everything works as I want. thanks again for your assistance. 🙂 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (2,079)