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?
Concatenate an Auto Increment into the Text Formula with your other fields and it would give you a unique value.
Ok - so how do you enforce that uniqueness of the text formula?
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.
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. I have recently written a blog post about multi field uniqueness using Integromat in fact:
I hope you find this useful!!
Julian
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.
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
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.
Check on below url
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
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.
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
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.
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
+919855089359
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.
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.
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!
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;
}
look like you face this error due to " … here sometime it’s changes with other char.
change all " to ’ and then try
Sure will check your code.
my email is ssingla1985@gmail.com you can share your app with me. we can check . Instead display none we need to use hide using visibility : hiddien