# Add new data access level to Knack App

**URL:** <https://forums.knack.com/t/add-new-data-access-level-to-knack-app/11558>\
**Category:** Get Answers\
**Created:** [November 15, 2021, 9:45pm UTC](https://forums.knack.com/t/add-new-data-access-level-to-knack-app/11558 "2021-11-15T21:45:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jan](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@Jan](https://forums.knack.com/u/Jan)\
**Post date:** [November 15, 2021, 9:45pm UTC](https://forums.knack.com/t/add-new-data-access-level-to-knack-app/11558/1 "2021-11-15T21:45:44Z")

</div>

Hello, I’m just wandering if is possible to have unique key in table created by 2 (or more) unique fields. It is nice that Knack is watching unicity on every field signed as unique, but I need to combination will be unique.

For example:

- Object is Car,
- having fields:
- color
- owner
- user - unique
- VIN (engine code) - unique

I would like to have more records for one car like this:

- user A using car 1
- user B using car 2
- user A using car 2

Is possible to do that somehow?

I can use text formula field, which can combine two unique fileds. But formula field cannot be unique (so I cannot rely on automatical record check before insertion).

1. solution proposal:  
I am thinking about some mapping object (CAR\_USING) with unique field in type of string or integer in which combination of USER+VIN can be encoded.

- But this will enlarge the database size a lot…

1. solution proposal:  
On every insert/update to CAR, check uniqueness by JS.

- But I found this not robust enough, JS sometimes not run/finish good.

What do you think…? I would appreciate any suggestions.

---

<div class="post-metadata">

**Author:** ![Steve](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/steve/32/735_2.png) [@Steve](https://forums.knack.com/u/Steve)\
**Post date:** [November 15, 2021, 9:58pm UTC](https://forums.knack.com/t/add-new-data-access-level-to-knack-app/11558/2 "2021-11-15T21:58:03Z")

</div>

Hi Jan,

We have a feature we call [Connections](https://learn.knack.com/article/do520qb4jz-about-connections) that enables you to build the proper relationship between Objects. In the example you provided, you would require a one-to-many relationship between the Car Object (one) and Owners object, for example (many).

The VIN can serve as the unique field assigned from Car to many separate Owner records.

Functionally, this would allow you to add car records and view a child page of owner records for the same vehicle similar to the example in this [guide](https://learn.knack.com/article/ye44wcypkr-showing-parent-child-records-in-the-live-app).

Hope this helps!

---

<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:** [November 16, 2021, 4:17pm UTC](https://forums.knack.com/t/add-new-data-access-level-to-knack-app/11558/3 "2021-11-16T16:17:06Z")

</div>

Hi @Jan

If I understand correctly, you are looking for a way to prevent records being created with duplicate values - but these values are from more that one field?

As you probably have realised this is not a Knack native feature at the moment but I have devised a way of doing this using a bit of Javascript code in Knack and an Integromat Scenario - you can read about it on my blog:

> **[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...

In terms of your solutions you list, assuming I understand, then I think option 1 is the place to start - then use this validation with it.

Julian

---

<div class="post-metadata">

**Author:** ![Jan](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@Jan](https://forums.knack.com/u/Jan)\
**Post date:** [November 23, 2021, 10:55am UTC](https://forums.knack.com/t/add-new-data-access-level-to-knack-app/11558/4 "2021-11-23T10:55:37Z")

</div>

Hi, not much 🙂 … We have quite complex knack app and for my example - I still need to add records directly to one object (Car). Just disable unique key and check it some other way on combination of fields.

And I would need to change lot of thinks on desing change. But I agree that design is wrong at this point, I just must to live with…

---

<div class="post-metadata">

**Author:** ![Jan](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@Jan](https://forums.knack.com/u/Jan)\
**Post date:** [November 23, 2021, 11:01am UTC](https://forums.knack.com/t/add-new-data-access-level-to-knack-app/11558/5 "2021-11-23T11:01:00Z")

</div>

Thank you Julian! I like this! And I’ll probably use it…

I’ll just try to do JS more reusable to have more code for all form checks if possible. I need to test it but I believe I can do it like this:  
1] have one function/header for each form i have ro check  
- $(document).on(‘knack-view-render.view\_332’, function (event, view, data)  
2] have same body and just passing different view\_id and field\_id
