cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vffdd
Super User
Super User

Duplicate detection in collection

I have a blank gallery to which I dynamically add rows however many I need and then add data to those rows.   On save I create a collection from that data and then I patch it back to a sharepoint list.     All works well.

 

However I now need the functionality to check for duplicates in one of the columns (it's text input, number type) before I patch it through to the sharepoint list. notify the user and give them a chance to update it..  (notify function would be absolutely fine for this)

 

I have read numerous duplicate questions, watch a ton of videos but can't quite get the scenario I need.

 

So somewhere between Collect(mycollection.....  and Patch (mycollection  I need an If duplicate then notify if not then patch !

 

Any ideas gratefully accepted

 

TIA

1 ACCEPTED SOLUTION

Accepted Solutions

@vffdd Check this out,

ClearCollect(mySPCollection, ["1","2","2","3","4","4","5"]);
If(CountIf(AddColumns(GroupBy(mySPCollection,"Value", "myGroup"), "myCount", CountRows(myGroup)), myCount>1)>0, 
Notify("Duplicates Found"),
Patch(.......); Navigate(.....))

In this case Patch and Navigate will be executed ONLY if there are no duplicates!

 

Please remember to give a 👍 and accept my solution as it will help others in the future.

View solution in original post

5 REPLIES 5
CNT
Super User
Super User

@vffdd Follow this example and replace mySPCollection with your collection name and Value with the name of your column.

ClearCollect(mySPCollection, ["1","2","2","3","4","4","5"]);
If(CountIf(AddColumns(GroupBy(mySPCollection,"Value", "myGroup"), "myCount", CountRows(myGroup)), myCount>1)>0, Notify("Duplicates Found"))

 

Please remember to give a 👍 and accept my solution as it will help others in the future.

vffdd
Super User
Super User

brilliant thanks @CNT   I'm almost there.. that worked but showed up another issue I have by making it work 🙂   The next command after the collection has been patched is to navigate to another screen and it's just another command separated by ; from the rest.  However IF there is a duplicate and patch doesn't happen I don't want to navigate?  because I want them to fix it.. I only want to navigate if the patch has taken place.. so how do I join the navigate to the end of the patch as opposed to it being a separate command?  I know if it was a form I could use an on success but don't think there anything similar in patch?   

@vffdd Check this out,

ClearCollect(mySPCollection, ["1","2","2","3","4","4","5"]);
If(CountIf(AddColumns(GroupBy(mySPCollection,"Value", "myGroup"), "myCount", CountRows(myGroup)), myCount>1)>0, 
Notify("Duplicates Found"),
Patch(.......); Navigate(.....))

In this case Patch and Navigate will be executed ONLY if there are no duplicates!

 

Please remember to give a 👍 and accept my solution as it will help others in the future.

vffdd
Super User
Super User

Fantastic, thanks so much amazing what moving a bracket can do !!  🙂

@vffdd 

Glad to help!

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Solution Authors
Top Kudoed Authors
Users online (4,002)