Must be Unique

Is there a way to set the field to “must be unique” to on but if that particular field has a value of “N/A” in multiple records, I’d like to be able to save it without getting an error message that “value must be unique”

Example: field “location” has a value of “N/A” for a current record and a user tries to input “N/A” for another record for the same field, when the must be unique is checked, an error message is shown. To override this, we have to log into builder, uncheck must be unique, input data then re-check must be unique. Basically I want to override the must be unique if the value “N/A” is inputted on the user’s side.

Thank you… JON

Hi Jon1,

I do this often using Javascript and a hidden Search view.

Here’s the trick:

  1. When the value is not “N/A” and the user clicks Submit, you prevent the click action with e.preventDefault();
  2. You copy the value entered in the field and paste it in the Search field, set-up for an exact match on that same field being submitted.
  3. After the search outcome, you end up with zero or one record.
  4. If zero, you click the Submit button in the initial form.
  5. If one, you generate: alert(‘Sorry, value already exists.’);

I also use this to implement my own “Must be Unique” on connected fields.

Actually, I think that this would be a cool new feature in the KTL: searchValue(value, fieldId, viewId) returning Promise with a count, or record Id array…

If you need more information, I can assist you.
Normand D.

Any chances of getting a javascript for this?

Hi Jon,

I’ve just completed the feature we both need. It really rocks!

I had this implemented at several places in my client’s code, but I can now delete all this redundancy and use this new method from now on.

Go see it here: Allow duplicates value on specific fields and words
Just sign-up and you’ll see it in action.

The way the code is done is so that you can have the “N/A” duplicate word as you wanted, but I went a step further and made it to allow specifying more than one field and more than one word for each form.

The new field keyword is _uvx=allowedDup1, allowedDup2,…. Stands for “Unique Value Exceptions”
Ex: _uvx=N/A,Sample
You set it for each field’s description that you need, in the object page.
It uses a hidden Search view and sequences all searches in the background, and pops-up an alert with the details of all duplicates found. If none, the Submit is done automatically and the Item view below is refreshed also using the _rvs=Items keyword.

Here’s the setup for the fields:

In this case, the SKU field will allow N/A and Eval as possible duplicates.
The other field (not shown here) is Item and has this keyword: _uvx=N/A,Sample
So we end up with two fields, each having two exceptions. Now that’s very flexible!

Here are the views setup:

The Search Items view has the same Source as the Form, and the two fields that you need exceptions on. Both must have the Exact Match enabled. Title or description must contain _uvx to map the feature correctly between the two views.

What is nice with the KTL, is that you can re-use the same code over and over, and get tons of other cool features as a bonus.

You already have all the code - and it’s yours!
Everything is in the KTL.js file here: Knack-Toolkit-Library/KTL.js at master · cortexrd/Knack-Toolkit-Library (

I would love to be “super nice” and spend tens of hours reverse-engineering myself to extract only this feature’s code, but I think that I’ve been generous of my time already! Anyways… everything in the KTL is so tied-up in a monolithic package, that it would be a big waste of time to try to undo all this.

But still, if you’re interested in understanding how it works, it involves these functions:

  • preprocessSubmit
  • getFieldsKeywords
  • parseKeywords
  • processFieldsKeywords
  • findRecordByValue

For about 150 lines of code total, just for the core of that feature. Hundreds more if you dig deeper into the functions.

Hope you like it,

Hi Jon,

Here’s the link to my latest tutorial where I mention this post and do a demo.

Introducing the Knack Toolkit Library - demo part 2 - YouTube


Hi Norm, just watched your YouTube video on your KTL features including that one in this post.

That’s exactly what I was looking for. Now I just have to figure out how to implement it into my app.

Keep up the great work… JON

1 Like

Now, I’m really happy to read this Jon!

I need to update the documentation, as this new _uvx keywords is not yet written.

But give it a try in a test page, by following what I say in the video and you should be good. If you have questions, let me know.