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.

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
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.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

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
Top Kudoed Authors
Users online (1,852)