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 Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

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.

Users online (3,713)