{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"type":"markdown"},"seo":{"title":"Conditional custom fields","meta":[{"name":"robots","content":"noindex"}],"llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"conditional-custom-fields","__idx":0},"children":["Conditional custom fields"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This guide explains how to set a custom field to only appear only when the traveler gives a particular answer to another custom field."," ","For example, a company might ask whether a traveler is extending their stay, and collect an emergency contact number only if the traveler answers ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Yes"]},"."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Be sure to read ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/spotnana/basic_custom_field_concepts"},"children":["custom field concepts"]}," to familiarize yourself with this feature before starting to use it."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"creating-the-main-custom-field","__idx":1},"children":["Creating the main custom field"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create the custom field that asks a question. For example, ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Are you planning to extend your stay?"]},"."," ","You would do this using the ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/openapi/customfieldapi/custom-field-v3/createcustomfieldv3"},"children":["create custom field"]}," endpoint as shown below:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","data-title":"POST /v3/companies/{companyId}/custom-fields?companyRole=ORG","header":{"title":"POST /v3/companies/{companyId}/custom-fields?companyRole=ORG","controls":{"copy":{}}},"source":"{\n  \"name\": \"Are you planning to extend your stay?\",\n  \"description\": {\n    \"value\": \"Captures whether the traveler stays beyond the event dates\"\n  }\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Add an arm with a ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/openapi/customfieldapi/custom-field-v3/createarm"},"children":["create custom field arm"]}," request."," ","This arm has no audience conditions, so it applies to every traveler who makes a booking."," ","The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["action"]}," is set to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["USER"]}," and the option source ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["type"]}," is set to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["MANUAL"]}," as it requires a manual response from the traveler."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The API response contains an ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["optionGroupId"]}," which will be used in ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"#creating-the-dependent-custom-field"},"children":["creating a dependent custom field"]},"."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","data-title":"POST /v3/companies/{companyId}/custom-fields/{customFieldId}/arms","header":{"title":"POST /v3/companies/{companyId}/custom-fields/{customFieldId}/arms","controls":{"copy":{}}},"source":"{\n  \"name\": \"All travelers\",\n  \"action\": {\n    \"type\": \"USER\",\n    \"required\": true,\n    \"format\": {\n      \"type\": \"OPTION_LIST\",\n      \"optionListTypeFormat\": {\n        \"isMultiSelect\": false,\n        \"isPctType\": false\n      },\n      \"customValueFormat\": {\n        \"isCustomValueAllowed\": false\n      }\n    },\n    \"userOptionSource\": {\n      \"type\": \"MANUAL\"\n    }\n  }\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Add the two answers with an ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/openapi/customfieldapi/custom-field-v3/updatecustomfieldoptiongroupv3"},"children":["update options"]}," API call."," ","The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["name"]}," of each option will be displayed to the traveler for them to choose."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","data-title":"PATCH /v3/companies/{companyId}/custom-fields/{customFieldId}/option-groups/{optionGroupId}","header":{"title":"PATCH /v3/companies/{companyId}/custom-fields/{customFieldId}/option-groups/{optionGroupId}","controls":{"copy":{}}},"source":"{\n  \"toUpdate\": [\n    {\n      \"name\": \"Yes\"\n    },\n    {\n      \"name\": \"No\"\n    }\n  ]\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"creating-the-dependent-custom-field","__idx":2},"children":["Creating the dependent custom field"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create the second custom field using the same ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/openapi/customfieldapi/custom-field-v3/createcustomfieldv3"},"children":["create custom field"]}," endpoint."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","data-title":"POST /v3/companies/{companyId}/custom-fields?companyRole=ORG","header":{"title":"POST /v3/companies/{companyId}/custom-fields?companyRole=ORG","controls":{"copy":{}}},"source":"{\n  \"name\": \"Enter your emergency contact number\",\n  \"description\": {\n    \"value\": \"Collected only when the traveler extends their stay\"\n  }\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/openapi/customfieldapi/custom-field-v3/createarm"},"children":["Create a custom field arm"]}," to include it's dependency on the ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"#creating-the-main-custom-field"},"children":["main custom field"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Set the following values:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["audience"]}," > ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["predicates"]}," > ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["type"]}," as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CUSTOM_FIELD_RESPONSE"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["id"]}," as the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["optionGroupId"]}," of the main custom field's ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"#creating-the-main-custom-field"},"children":["arm"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["comparator"]}," as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["EQ"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["values"]}," as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Yes"]},"."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The above set of conditions translates to: ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Answers where the main custom field response equals to ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Yes"]}]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Now that we have the condition, set the action in the same API request as follows:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["action"]}," > ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["type"]}," as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["USER"]}," (i.e., requires a user input)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["format"]}," > ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["type"]}," as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TEXT_INPUT"]}," (i.e., the user needs to type into a text box)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["allowedChars"]}," as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["NUMERIC"]}," (i.e., only allow numbers since the user is entering their phone number)."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Below is a sample request where all the fields mentioned above are being set as described:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","data-title":"POST /v3/companies/{companyId}/custom-fields/{customFieldId}/arms","header":{"title":"POST /v3/companies/{companyId}/custom-fields/{customFieldId}/arms","controls":{"copy":{}}},"source":"{\n  \"name\": \"Travelers extending their stay\",\n  \"audiences\": [\n    {\n      \"name\": \"Answered Yes to the extended stay question\",\n      \"predicates\": [\n        {\n          \"type\": \"CUSTOM_FIELD_RESPONSE\",\n          \"id\": \"c73b1e58-9d24-4f07-a6b8-1e5c9d380f2a\",\n          \"comparator\": \"EQ\",\n          \"values\": [\n            \"Yes\"\n          ]\n        }\n      ]\n    }\n  ],\n  \"action\": {\n    \"type\": \"USER\",\n    \"required\": true,\n    \"format\": {\n      \"type\": \"TEXT_INPUT\",\n      \"userInputFormat\": {\n        \"type\": \"NON_REGEX\",\n        \"allowedChars\": \"NUMERIC\",\n        \"minLength\": 7,\n        \"maxLength\": 15\n      }\n    }\n  }\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Every new custom field is disabled by default."," ","Use the ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/openapi/customfieldapi/custom-field-v3/updatecustomfieldstatus"},"children":["update custom field status"]}," endpoint to enable the custom fields using their ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ids"]},"."]}]}]},"headings":[{"value":"Conditional custom fields","id":"conditional-custom-fields","depth":1},{"value":"Creating the main custom field","id":"creating-the-main-custom-field","depth":2},{"value":"Creating the dependent custom field","id":"creating-the-dependent-custom-field","depth":2}],"frontmatter":{"seo":{"title":"Conditional custom fields"}},"lastModified":"2026-09-16T16:41:37.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/guides/custom_field_guides/custom_field_conditional_guide","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}