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

Question / Problem

Hi, I am currently setting up an App using the 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 API to set up a Field group?

In the App, I want a Field group 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 in an App that pulls data from a source App.

Thanks in advance!

Referenced Resources

Field group related:

Lookup field related:

@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!

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 to place fields within that group field.

Here's an example for better understanding:

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 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!

2 Likes