cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RodRollTech
Level: Powered On

Prevent duplicate values in a collection (data validation)

I'm experimenting with collections to associate two pieces of data with each other and I'm looking for a way to prevent duplicates. I want to put a coil with a unique ID number onto one of 75 hooks, and I want to ensure that when the coil ID is being associated with a hook number, that I can't associate two coil IDs with one hook, or put the same coil ID on two hook numbers. I had thought of using an 'IF' function (e.g. IF [new hook number] = [hook number already in collection] THEN [show error message]) but I'm not sure if 'IF' functions will work with collections. Any suggestions on how I could do this?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Meneghino
Level 10

Re: Prevent duplicate values in a collection (data validation)

Hi @RodRollTech

The 'in' operator is what you need, and yes you can use the if function to control programme flow when collecting an item into a collection.

If you provide more details, I can provide a more detailed answer.

View solution in original post

Highlighted
Meneghino
Level 10

Re: Prevent duplicate values in a collection (data validation)

Hi @RodRollTech

You want to simply disable the button if the data is already present in the collection.

So you want to set the DisplayMode property of the button to something like this:

If(hook.text exactin YourCollectionName.hooks, Disabled, Enabled)

Hope this helps, please let me know

View solution in original post

4 REPLIES 4
Meneghino
Level 10

Re: Prevent duplicate values in a collection (data validation)

Hi @RodRollTech

The 'in' operator is what you need, and yes you can use the if function to control programme flow when collecting an item into a collection.

If you provide more details, I can provide a more detailed answer.

View solution in original post

RodRollTech
Level: Powered On

Re: Prevent duplicate values in a collection (data validation)

Hi Meneghino,

 

Thanks for that, I was able to create another data table and set its Items property to 'Filter(Collection, hook.text exactin hooks)' and it displayed what was in the 'Hook' text input control. Now what I'm trying to do is to marry this with the If function so that when I press a button with OnSelect = Collect(Collection, {Bundles:BundleID.Text, Hooks:Hook.Text}), a check is performed to see if the hook number or bundle ID already exists in the collection, in which case the new record isn't added to the collection. I'm also amenable to changing the colour or text of the input boxes/button if the hook/bundle already exists in the collection.

Highlighted
Meneghino
Level 10

Re: Prevent duplicate values in a collection (data validation)

Hi @RodRollTech

You want to simply disable the button if the data is already present in the collection.

So you want to set the DisplayMode property of the button to something like this:

If(hook.text exactin YourCollectionName.hooks, Disabled, Enabled)

Hope this helps, please let me know

View solution in original post

RodRollTech
Level: Powered On

Re: Prevent duplicate values in a collection (data validation)

Thanks Meneghino, implemented and working well!

Helpful resources

Announcements
thirdimage

Power Platform 24

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,165)