# Combine fields to make a unique record

**URL:** <https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824>\
**Category:** Get Answers\
**Created:** [January 3, 2022, 9:58pm UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824 "2022-01-03T21:58:56Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Randall](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/randall/32/153_2.png) [@Randall](https://forums.knack.com/u/Randall)\
**Post date:** [January 3, 2022, 9:58pm UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/1 "2022-01-03T21:58:57Z")

</div>

Is there any way to make a text formula field, unique? I would like to combine brand, product and part number fields to become a unique record in the table. In database terms we call it a clustered index. Is this possible in knack?

---

<div class="post-metadata">

**Author:** ![CarlHolmes](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/carlholmes/32/2814_2.png) [@CarlHolmes](https://forums.knack.com/u/CarlHolmes)\
**Post date:** [January 3, 2022, 10:14pm UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/2 "2022-01-03T22:14:14Z")

</div>

Concatenate an Auto Increment into the Text Formula with your other fields and it would give you a unique value.

> **[Text Formulas](https://learn.knack.com/article/r3edi1pk8v-text-formulas#add_a_text_formula)**
>
> What is a Text Formula? Text Formulas are fields that combine multiple text values into a single field, including values from other fields. Text formulas are very similar to equations and can be adde…

---

<div class="post-metadata">

**Author:** ![Randall](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/randall/32/153_2.png) [@Randall](https://forums.knack.com/u/Randall)\
**Post date:** [January 3, 2022, 10:25pm UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/3 "2022-01-03T22:25:31Z")

</div>

Ok - so how do you enforce that uniqueness of the text formula?

---

<div class="post-metadata">

**Author:** ![CarlHolmes](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/carlholmes/32/2814_2.png) [@CarlHolmes](https://forums.knack.com/u/CarlHolmes)\
**Post date:** [January 4, 2022, 6:44am UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/4 "2022-01-04T06:44:00Z")

</div>

You can’t enforce it as you can’t make a text formula field “unique” as a field option. However, each entry will be unique even if the other details are identical as each field will have a different auto increment.

---

<div class="post-metadata">

**Author:** ![JulianKirkness](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/juliankirkness/32/770_2.png) [@JulianKirkness](https://forums.knack.com/u/JulianKirkness)\
**Post date:** [January 4, 2022, 12:54pm UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/5 "2022-01-04T12:54:41Z")

</div>

Hi @Randall

Carl is correct in what he says - however it would be possible to do in Javascript - or simpler, a combination of some simple Javascript and [Integromat](https://www.integromat.com/?pc=kirkness). I have recently written a blog post about multi field uniqueness using Integromat in fact:

> **[Knack Multi-Field Uniqueness with Integromat](https://www.onlinedatabase.expert/post/knack-multi-field-uniqueness-with-integromat)**
>
> A question asked often in the Knack forums and elsewhere is how to prevent a user from booking onto the same course twice - or in the case of the example we are going to use (because I had the database handy), to stop a duplicate record associating a...

I hope you find this useful!!

Julian

---

<div class="post-metadata">

**Author:** ![Naazneen](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@Naazneen](https://forums.knack.com/u/Naazneen)\
**Post date:** [October 9, 2022, 7:58am UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/6 "2022-10-09T07:58:52Z")

</div>

The purpose of having a unique field is to prevent duplicate records for the same data/input record. The auto-increment will still enable multiple duplicate records, just that each duplicate will have a new Auto-Increment no. That doesn’t solve the problem of blocking duplicates. Is there any other workaround for this yet? Apart from the external integration with Integromat.

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [October 9, 2022, 8:16am UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/7 "2022-10-09T08:16:31Z")

</div>

Hello Naazneen,

We can achieve this using Javascript based on requirements. We just need to create a text field and mark it as unique (without javascript user need to put values in it manually and with javascript we can use it as a formula.

Regards,  
Sunny Singla

---

<div class="post-metadata">

**Author:** ![Naazneen](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@Naazneen](https://forums.knack.com/u/Naazneen)\
**Post date:** [October 9, 2022, 8:22am UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/8 "2022-10-09T08:22:04Z")

</div>

Thank you for the reply. I need to make a formula field unique, and i am not too well-versed in JS. Can you provide me with a little more detailed help on this? I just need to put in a check for a combo field (short text 1+short text 2). Want to make sure the combo field is unique before the form is submitted.

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [October 9, 2022, 8:34am UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/9 "2022-10-09T08:34:22Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/7/75d1cf15023c95aef478986ec96529769799aa9e.png)

Check on below url  
[https://roberts.knack.com/farmers#checkuniqueness/](https://roberts.knack.com/farmers#checkuniqueness/)  
javascript used

$(“#field\_281 , #field\_282”).live(“change , blur”,function(){

$(“#field\_283”).val($(“#field\_281”).val()+" “+$(”#field\_282").val());  
});

Thanks,  
Sunny Singla

---

<div class="post-metadata">

**Author:** ![Naazneen](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@Naazneen](https://forums.knack.com/u/Naazneen)\
**Post date:** [October 11, 2022, 7:15am UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/10 "2022-10-11T07:15:54Z")

</div>

> [@Sunny\_Singla](#):
>
> $(“#field\_281 , #field\_282”).live(“change , blur”,function(){
> 
> $(“#field\_283”).val($(“#field\_281”).val()+" “+$(”#field\_282").val());  
> });

I used the above code but i get the msg “private identifiers are not allowed outside class bodies”. I dont know js. Not sure how to rectify this.

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [October 11, 2022, 12:03pm UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/11 "2022-10-11T12:03:41Z")

</div>

Hello Naazneen,

Didn’t encounter this issue before. Can you attach a screenshot of where you added that code?

You need to add that code into the js part of knack.

Regards,  
Sunny Singla

---

<div class="post-metadata">

**Author:** ![Naazneen](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@Naazneen](https://forums.knack.com/u/Naazneen)\
**Post date:** [October 12, 2022, 7:53am UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/12 "2022-10-12T07:53:19Z")

</div>

The issue was with my format of open and close quotes. That issue is resolved now. Thanks.

The formula is working for fields now, which is great. But for fields that have multi sub-fields eg Name (First and Last), then when concatenating say Name with Email, I get the output as undefined {email}. Any way to extract just the First Name of the Name field and concatenate that with the Email, to get the new unique field.

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [October 12, 2022, 8:58am UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/13 "2022-10-12T08:58:43Z")

</div>

Hello,

I think you need to inspect a proper id and then add it to the code.  
for professional help, you can also contact me my email or phone.

Regards,  
Sunny Singla  
[ssingla1985@gmail.com](mailto:ssingla1985@gmail.com)  
+919855089359

---

<div class="post-metadata">

**Author:** ![Naazneen](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@Naazneen](https://forums.knack.com/u/Naazneen)\
**Post date:** [October 13, 2022, 4:20am UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/14 "2022-10-13T04:20:51Z")

</div>

Sure I will, going forward. At first, I m still trying to gauge whether I can do simple tasks in Knack myself, before investing a lot of time and effort in it. And before I recommend it to others I want to be a little more conversant with basic functionalities. A unique combo field is the bare minimum requirement to prevent duplicate Form entries. That should not be too difficult to resolve.

Back to my query, if I were not to extract elements of the Name field array and go with using the Full Name field, I am still unable to get the value of the Name field using the javascript/jquery that you have given. The value returned is ‘undefined’ for the Name field. The value of the email field (or any other text field) is correctly picked up. What is the formula missing wrt getting the value of the Name field?

Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [October 13, 2022, 7:35am UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/15 "2022-10-13T07:35:50Z")

</div>

Undefined only comes if that field does not exist on that page. Or you are using the wrong id or class.

Share your code and page URL where you apply that code.

---

<div class="post-metadata">

**Author:** ![JDWorleyKY](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@JDWorleyKY](https://forums.knack.com/u/JDWorleyKY)\
**Post date:** [November 10, 2022, 5:34pm UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/16 "2022-11-10T17:34:34Z")

</div>

I’m also getting a syntax error on this code snippet Sunny. Can you take a look and help me out in finding the issue? Thank you!  
 ![Screen Shot 2022-11-10 at 12.32.58 PM](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/e/e58a355afcbf1cbb0eab1375f072abbc719745f9.png)

---

<div class="post-metadata">

**Author:** ![JDWorleyKY](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@JDWorleyKY](https://forums.knack.com/u/JDWorleyKY)\
**Post date:** [November 10, 2022, 6:20pm UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/17 "2022-11-10T18:20:07Z")

</div>

Also @Sunny_Singla , I’m trying to hide the text formula field with CSS like you suggested, but it just wont hide, can you check my code here too to see what i’m doing wrong? Thank you! Happy to pay you for your help as well.  
#kn-input-field\_1403 {  
display:none !important;  
}

 ![Screen Shot 2022-11-10 at 1.19.48 PM](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/a/aeda50fe9e544255de27caa2f9118e56f5fd3f40.png)

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [November 10, 2022, 6:23pm UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/18 "2022-11-10T18:23:33Z")

</div>

look like you face this error due to " … here sometime it’s changes with other char.

change all " to ’ and then try

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [November 10, 2022, 6:29pm UTC](https://forums.knack.com/t/combine-fields-to-make-a-unique-record/11824/19 "2022-11-10T18:29:16Z")

</div>

Sure will check your code.

my email is [ssingla1985@gmail.com](mailto:ssingla1985@gmail.com) you can share your app with me. we can check . Instead display none we need to use hide using visibility : hiddien
