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.



I’ve just completed the documentation update and a few bug fixes with _uvc and _uvx keywords.
You can go see the doc here: Advanced Keywords Setup

Hope you’ll find the procedure crystal clear, but if not let me know.


Thank you Normand… JON

Normand, I been messing around with your KTL add on the that last few days and I really like it. One thing I can’t figure out is how to stop KTL from changing the font in some of the labels to a default blue color. I’m sure it something simple but can’t figure it out.

Thank you… JON

Hi Jon,

I know that the _ts (Time Stamp) keyword is currently hard-coded to a blue bold font. I could modify this behavior to add a user-defined custom style.

Otherwise, I can’t see where…
Can you send a screen grab?


Hey Norm, thank you for the reply… I’ve attached (2) screen prints of a quick sample program I created.

One is with of your KTL installed, one is without KTL. As you can see, when I install you KTL starter app, all the fonts are changed to blue both on the table view and in the details view. Remove your KTL starter script and the fonts are back to black. I inspected the page in Chrome and it appears the fonts are getting set to the colors 67,61,198 with your KTL app installed. If I change the font colors in the inspector window from 67,161,198 to 0,0,0 once again back to black. But as you know, this is only temporary. Thinking it was isolated to just one app, I tried it in multiple apps on multiple table and detail view, including this very simple sample app, with same unpleasant result…

Very strange indeed. I don’t see that color anywhere in KTL’s code. None of my apps do that.
Can you share that app with me for further investigation?
Or maybe give a few more details about your theme settings?


Hey Norm, I’ve been messing with different settings in Knack and I found a work around for the blue text colors for both the table’s data and the labels on a detail views when your KTL starter is installed.

I went into "live app design, look and feel and change the “link color” to #000000 (black) which corrected the blue text colors for the data in the table’s and the labels in details view pages. I did this for all my programs including a very simple example app that had a table and detail view.

Not sure why this is happening because none of the text are links and some of them were labels in the details view pages.

Only bad thing now is that the link text I wanted as blue (ie Menus) is now black…

1 Like

Very interesting. I can now get the same behavior as you, when I change that parameter.
What I don’t understand is why the description says “This will affect links, button text, and grid headers.
But clearly, it also affects plain value text as in third column in this screen grab.

In fact it does quite the opposite of what it says since the table headers are black!!!

I think this deserves a bug report.

In the meantime, I will see if I can find a quick fix to that, and maybe add it in the KTL as a feature.

Thank you for the additional info,

Thank you sir…

1 Like

Here’s a solution to add to your CSS pane:

td [href] {
  color:#00009f !important;
  font-weight: 500;

This will colorize all links in a table, except the headers to a deep blue and slightly bolder font. Change to your liking of course.

Leave the Look and feels’ Link color to black.

If you prefer, this also works in the Javascript pane:

$(document).on('knack-view-render.any', function (event, view, data) {
    $('#' + view.key + ' td [href]').css({ 'color': '#00009f', 'font-weight': '500' });

Note to self: add this to KTL as a feature!


Thank you… that worked for the links in the table.

I got the following code to work for the “back to link” at bottom of pages:
a.ang-link { color: #036dfc !important;}

Can’t figure out the how to change the menu link colors from black, any suggestions or help?

Thanks again… JON


.kn-menu .kn-button { color:#036dfc !important }


Hey Norm, appreciate the quick response.

I tried that code earlier and it doesn’t work to change the menu link colors.