cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vffdd
Post Prodigy
Post Prodigy

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
Post Prodigy
Post Prodigy

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
Post Prodigy
Post Prodigy

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

@vffdd 

Glad to help!

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.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,904)