Prevent duplicate records in data store

I have a situation where on button click it currently adds to local storage. I want to prevent duplicate entries that share the same id.

I have tried using the disable function in app connect to disable the button if the id exists in the data store but the closest I can get is to only disable when the id is value[0].id. Any ideas?

Trying using this in the code:


Maybe the best way is to set the id As primary key in database.

Here’s an example of what I’m trying to do. I have a list of values with a button next to each one.

Blue (1)
Red (2)
Green (3)
Orange (4)
Purple (5)

On button click the value and its ID are sent to datastore. However I’m trying to disable the button when for example Green (ID: 3) is added to datastore so it can’t be added twice.

If it’s removed from datastore then the button should be active again.


That will only check the first value in your data store array, any subsequent value won’t get checked for your condition.

The way I check all the values in an array for a condition is by using the formatter in the dynamic data picker (the magic wand). Use the “values” formatter.

Hi, try this way:

  1. Do a server action with a query, for example “select * from table where id is = 3”

  2. In app structure select your server action

  3. Set up a dynamic attribute for your button, for example, hide my button if my query has items.

You could also do this with a show/hide condtion in App Connect, eg:

It should also be possible to use an expression like this to control what the button does, using a flow - ie without hiding the button.

1 Like

Works perfectly, thanks @TomD

1 Like