Preventing Duplicates (Uniqueness) on Combined Fields in an Object

same here.

Also need this to allow association where one Partner acts as support for another Partner - both IDs are from Partner object, and a Partner may have many Supporters and vice versa, but any combination must be unique.

Anybody ever get an answer to this???

 

Absolutely agree - Moderator, when is this coming?

1 Like

Hi,

Yes a must.

Thanks

Dan

Same issue here. I need to prevent users from submitting duplicate sales reports for the same date.

1 Like

I also need help with making a combined field unique.

I also need a way to do something similar. I don't see a reason why many fields can't be set as "Must be unique"

I just posted a request for this exact same thing!

I too have a similar but simpler issue.  I have a Products table with fields for Name and Version.  The combination of these two fields needs to be unique but I cannot figure out how to set this up.


Thanks for any help.

Gordon

I have a similar issue.  


I thought I had the answer by attempting to use the Text Formula field, however, the Text Formula field is absent the "Must be Unique" Flag, as well as any advanced settings to set validations.


Thank you,

Jason





Exactly same issue here!!!

We need to solve this as well. 

We have users entering dates (appointments) in a calendar which should not be duplicated.

I added one more nested If Else so that you can have 3 scenarios. I needed the ability to warn of duplicates but still allow for it if necessary. I removed the message on the Submit rule and instead added a custom message if the function comes back with just one record meaning there was no duplicate. If it doesn’t and a duplicate was found, then it offers two scenarios of create the duplicate anyway or delete it. In my case View_47 is the form being submitted - replace with yours. The var url = should be the url to your table where the record can be looked up. Replace the Scene and the View with your Table Scene and View. Field_238 is the field that contains the data you are checking for a duplicate, replace with yours.

// Begin Add Exercise check for Duplicate Name #################

$(document).on('knack-record-create.view_47', function(event, view, record) {

    var headers = { "X-Knack-Application-ID": Knack.app.id,
   "Authorization": Knack.getUserToken(),
   "Content-Type":'application/json'};

   var url = 'https://api.knack.com/v1/pages/scene_24/views/view_1448/records';

   // Prepare filters
   var filters = {
     'match': 'and',
     'rules': [
       {
         'field':'field_238',
         'operator':'is',
         'value':record.field_238
       }
     ]
   };

   // Add filters to route
   get_url = url + '?filters=' + encodeURIComponent(JSON.stringify(filters));

   

   $.ajax({
    url: get_url,
    type: 'GET',
    headers: headers,
    success: function (response) {
        if (response.records.length == 1) {
          alert("Your Exercise has been created!");
        } else {

            var result = confirm("An Exercise with this name already exists, you may click OK to continue and create it as is with the duplicate name or you may choose Cancel and we will delete this Exercise");

            if (result) {
                alert("Your Exercise has been created!");
            } else {
                alert("Your Duplicate Exercise was Deleted, your original is still in the Exercise Library");
                $.ajax({
                    url: url += '/' + record.id,
                    type: 'DELETE',
                    headers: headers,
                    success: function (response){}
             
          
            });
         }
       }
     }
   });

});

// End Add Exercise check for Duplicate Name #################
[/quote]



// Begin Add Exercise check for Duplicate Name #################

$(document).on('knack-record-create.view_47', function(event, view, record) {

    var headers = { "X-Knack-Application-ID": Knack.app.id,
   "Authorization": Knack.getUserToken(),
   "Content-Type":'application/json'};

   var url = 'https://api.knack.com/v1/pages/scene_24/views/view_1448/records';

   // Prepare filters
   var filters = {
     'match': 'and',
     'rules': [
       {
         'field':'field_238',
         'operator':'is',
         'value':record.field_238
       }
     ]
   };

   // Add filters to route
   get_url = url + '?filters=' + encodeURIComponent(JSON.stringify(filters));

   

   $.ajax({
    url: get_url,
    type: 'GET',
    headers: headers,
    success: function (response) {
        if (response.records.length == 1) {
          alert("Your Exercise has been created!");
        } else {

            var result = confirm("An Exercise with this name already exists, you may click OK to continue and create it as is with the duplicate name or you may choose Cancel and we will delete this Exercise");

            if (result) {
                alert("Your Exercise has been created!");
            } else {
                alert("Your Duplicate Exercise was Deleted, your original is still in the Exercise Library");
                $.ajax({
                    url: url += '/' + record.id,
                    type: 'DELETE',
                    headers: headers,
                    success: function (response){}
             
          
            });
         }
       }
     }
   });

});

// End Add Exercise check for Duplicate Name #################

Really disappointed to find out that the one to one relationships don’t actually work like that. Isn’t this a really basic feature of a database?

2 Likes

Hi @Marlene - you could adapt the Integromat process described in my blog article:

The basic idea should be the same even if you were only matching a single field.

Julian

I also need help with making a combined field unique.

Hello Jason,

checkout the below page.

or
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

This seems like a really essential feature to me also, and I faced it on the first day of letting my first user into my application that they added multiple copies of a data record into a table which has 2 fields.

I would need to combine the fields into one in order to avoid this it seems as I don’t know what Integromat is.

1 Like

Hi to all,

This feature is built-in the Knack Toolkit Library (KTL).
It’s called Unique Value Check and has the keyword _ucv.

See it here: GitHub - cortexrd/Knack-Toolkit-Library: Knack Toolkit Library
(search for Unique Value Check)

See a video demo here: KTL Demo #6 - Unique Value Check - for Connected fields and complex Text Formula fields - YouTube

Normand D.