cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PPSA
Resolver II
Resolver II

Compare two collections, output what is different

Afternoon all, I'm trying to find a way to notify a user of what changes were made to an edit form within my app.

I have created two collections, one when the edit form page is visible

PPSA_0-1596542345611.png

And another which is on the onchange property of my dropdown boxes.

PPSA_1-1596542398199.png

This works well in as much as it shows the modified data in the second collection.

I need to be able to compare the two though, filter to only show those that have been modified / do not match.

End goal is to then send a html table of the changes to a user - just not sure on how to compare the two, many thanks.

PPSA_2-1596542530923.png

 









1 ACCEPTED SOLUTION

Accepted Solutions

Sorry I was away for a while, try this.

ForAll(Addcolumns(OriginalRecordUserPermissions, "oldField",FieldName)
ForAll(NewRecordUserPermissions, 
         If(FieldName = oldField && OldValue <> newValue, Collect(colChanges, {
         	FieldName: FieldName,
        	FieldValue: newValue
     }))))

Once again sorry for the trouble and delay 😞


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

6 REPLIES 6
KrishnaV
Super User
Super User

Hi @PPSA ,

 

I see you are creating the collections with multiple columns create the collections with Row orientation as below:

Clear(OriginalRecordUserPermissions)
Collect(OriginalRecordUserPermissions,{FiledName:"PO1",OldValue:DataCardValue43.SelectedText.Value})
Collect(OriginalRecordUserPermissions,{FiledName:"PO2",OldValue:DataCardValue45.SelectedText.Value}) and so on....

Do the same to changed values collection also.

And then try this to find the changes:

ForAll(OriginalRecordUserPermissions,ForAll(NewRecordUserPermissions,If(OldValue=newValue,Collect(colChanges,{FieldName:FieldName,FieldValue:newValue}))))

 
I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

Thanks for your response @KrishnaV ,

I've restructed both collections now as below.

PPSA_0-1596546155331.png

PPSA_1-1596546171998.png


I added a button with your for all expression in to test and it isn't producing expected results, no doubt I may have misunderstood something?

PPSA_2-1596546249315.pngPPSA_3-1596546263586.png

I only changed the one record from 0 to 1.

Thanks



@KrishnaV  i have changed the for all expression slightly to be <> instead of = as I want to create the record for what has changed.

Now when I test this I get the modified record but 20 lines for each change, can we change this to just one line per change?

Thanks

PPSA_0-1596550067744.png

 

Small work around was to filter the gallery with FirstN(colChanges,Sum(CountRows(colChanges)/20))

Working for what I need although there's probably a fix somewhere.

Sorry I was away for a while, try this.

ForAll(Addcolumns(OriginalRecordUserPermissions, "oldField",FieldName)
ForAll(NewRecordUserPermissions, 
         If(FieldName = oldField && OldValue <> newValue, Collect(colChanges, {
         	FieldName: FieldName,
        	FieldValue: newValue
     }))))

Once again sorry for the trouble and delay 😞


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

Thanks @KrishnaV , I have this working now, just need to place the collection into a html table to be emailed out now.

I see your fairly active on here and know your stuff, could you have a little look at this thread i posted a few days back?

Only comment on there so far is somebody else is experiencing a similar issue.

Thanks for your time

https://powerusers.microsoft.com/t5/Building-Power-Apps/Losing-data-when-close-and-open-again/m-p/64...

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Users online (1,621)