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

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.

 

View solution in original post

@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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,568)