# How to set up a field group via API? How to verify a field's Prohibit duplicate values setting?

**URL:** <https://forum.kintone.dev/t/how-to-set-up-a-field-group-via-api-how-to-verify-a-fields-prohibit-duplicate-values-setting/801>\
**Category:** General\
**Tags:** lookup-field, prevent-duplicate, field-groups-field\
**Created:** [June 27, 2023, 4:02am UTC](https://forum.kintone.dev/t/how-to-set-up-a-field-group-via-api-how-to-verify-a-fields-prohibit-duplicate-values-setting/801 "2023-06-27T04:02:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tuankiet116](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/tuankiet116/32/35_2.png) [@tuankiet116](https://forum.kintone.dev/u/tuankiet116)\
**Post date:** [June 27, 2023, 4:02am UTC](https://forum.kintone.dev/t/how-to-set-up-a-field-group-via-api-how-to-verify-a-fields-prohibit-duplicate-values-setting/801/1 "2023-06-27T04:02:13Z")

</div>

## Question / Problem

Hi, I am currently setting up an App using the [Add Form Fields](https://kintone.dev/en/docs/kintone/rest-api/apps/add-form-fields/) API, and I have 2 questions about the Field group & Lookup fields.

### Question 1 - How to set up a Field group via API?

Can I use the [Add Form Fields](https://kintone.dev/en/docs/kintone/rest-api/apps/add-form-fields/) API to set up a [Field group](https://get.kintone.help/k/en/id/040525.html)?

In the App, I want a [Field group](https://get.kintone.help/k/en/id/040525.html) that includes all the required fields.

I cannot seem to find any article or document explicitly mentioning this.

### Question 2 - How can a field's Prohibit duplicate values setting be verified?

How do I verify whether a field's Prohibit duplicate values setting is enabled?

I have a [Lookup field](https://get.kintone.help/k/en/id/040526.html) in an App that pulls data from a source App.

Thanks in advance!

## Referenced Resources

Field group related:

- [Add Form Fields - Kintone Developer Program](https://kintone.dev/en/docs/kintone/rest-api/apps/add-form-fields/)
- [Field group field](https://get.kintone.help/k/en/id/040525.html)

Lookup field related:

- [Field Types - Kintone Developer Program](https://kintone.dev/en/docs/kintone/overview/field-types/)
  - ![Creating/updating of Lookup fields cannot be initiated with API tokens. The "Prohibit duplicate values" option must be checked for the Datasource App's key field.](https://canada1.discourse-cdn.com/flex035/uploads/kintone/original/1X/9b65f7c2c8bcd7280a6ba475b6b65a7dc980a408.png)

- [Lookup field](https://get.kintone.help/k/en/id/040526.html)
- [Prevent users from entering duplicate values with Prohibit Duplicate Values Fields' Settings - General - Kintone Developer Forum](https://forum.kintone.dev/t/prevent-users-from-entering-duplicate-values-with-prohibit-duplicate-values-fields-settings/625)

---

<div class="post-metadata">

**Author:** ![tuankiet116](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/tuankiet116/32/35_2.png) [@tuankiet116](https://forum.kintone.dev/u/tuankiet116)\
**Post date:** [June 28, 2023, 4:20am UTC](https://forum.kintone.dev/t/how-to-set-up-a-field-group-via-api-how-to-verify-a-fields-prohibit-duplicate-values-setting/801/2 "2023-06-28T04:20:51Z")

</div>

@Genji Hi, my question above is quite needs an answer as fast as it could be . Could you help me with that? Thank you in advance!

---

<div class="post-metadata">

**Author:** ![Chris](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/chris/32/44_2.png) [@Chris](https://forum.kintone.dev/u/Chris)\
**Post date:** [June 28, 2023, 10:44pm UTC](https://forum.kintone.dev/t/how-to-set-up-a-field-group-via-api-how-to-verify-a-fields-prohibit-duplicate-values-setting/801/3 "2023-06-28T22:44:21Z")

</div>

Hey @tuankiet116 ,

### Question 1

For your first question, you can indeed utilize the Add Form Fields API to set up a Field Group.

Interestingly, it's not clearly outlined in the English documentation, but the type you're looking for is `GROUP` for `properties.{fieldcode}.type`.

Just a quick sidebar: though not related to your query, Group Selection is defined as `GROUP_SELECT`.

Now, after you've successfully placed a group field in a form, you would have to engage the [Update Form Field API](https://kintone.dev/en/docs/kintone/rest-api/apps/update-form-fields/) to place fields within that group field.

Here's an example for better understanding:

```javascript
var body = {
  app: kintone.app.getId(),
  layout: [
    {
      "type": "GROUP",
      "code": "group",
      "layout": [
        {
          "type": "ROW",
          "fields": [
            {
              "type": "SINGLE_LINE_TEXT",
              "code": "str",
              "size": {
                "width": 200
              }
            }
          ]
        }
      ]
    }
  ]
};

```

### Question 2

For your second query, you can use the [Get Form Field API](https://kintone.dev/en/docs/kintone/rest-api/apps/get-form-fields/) to figure out whether the field has the "Prohibit duplicate values" option enabled.

This is identified through the `properties.{fieldcode}.unique` parameter.  
If it returns `true`, duplicate values are not allowed, but if it returns `false`, you are in the clear.

Remember, you can also find the related app in the `properties.{fieldcode}.lookup.relatedApp` parameter.

Hope this clears things up for you!
