Avoiding duplicate records with "only when"

I have a device as a type and one of the attributes is deviceID. I don’t want to have multiple records created with the same deviceID (i.e. I want to ensure uniqueness). Therefore, I put an “only when” entry on the “Create new device” which results in a search for a record with the same deviceID. In the subsequent steps which involve resetting the relevant inputs and putting up a success message, I’ve included an “only when” the result of the first step is “not empty”. However, I’d also like to show an alert that a device with that deviceID has already been registered. To accomplish that, I created a “show message” that points to my desired alert and included an “only when” and stated when the “result of the first step is empty”. However, this does not seem to work. What am I missing?

This is how I avoid a duplicate:

This works:

This does not work:

The best way to do this is to have your “Only When” as the opposite, so in your case count > 0.

The results of a step that hasn’t run may not be “empty” they may well be null or something. So it is unpredictable.

As a suggestion, asking your users to enter a load of stuff and THEN tell them they can’t do it … isn’t often great UX. So maybe do something progressive for the input, like ask for the device id first, then let them add all their stuff when you have OKed it ?

@NigelG, Thanks for the feedback. As it turns out, they only enter the device ID and a name, so it’s very little input before they try to add the record and potentially get an error message.

I’m not sure which Only When you’re referring to. I have an Only When (to confirm a record with that ID doesn’t exist) in the create step as well as in each of the following steps. I’m not sure which count you’re referring to.

Here’s my “complete” Create step:

So…I added a red text field indicating a record with that ID already exists and this data will not be added. I have a conditional on this field so it only shows up when a record with the same ID is present.

I also removed the alert object I had defined and the associated step in the create workflow.

Thanks, again, @NigelG

1 Like