Custom Field Types | Yext Hitchhikers Platform

What You’ll Learn

In this section, you will learn:

  • What a custom field type is
  • Example use cases of custom field types
  • How to create custom field types

What is a Custom Field Type?

As covered in the last unit, Yext has built-in custom field types that a user can select, like photo, single-line text, number, and many more. But what if you wanted to combine these together to build a new type?

Let’s say you wanted to create a “Promotion” object on your Location entity so that you could feature the promotion in Search and on your Pages. You want your promotion to include a name, a photo, a description, and a URL. Well, you could create 4 separate custom fields, and it could look like something like this on your Location entity:

promotion as separate fields

Sure, that works fine enough if you just have one promotion, but what if you want to add a second promotion?

Custom Field Types let you define a new complex field type using the standard field types as sub-fields. In the end, you have a custom type that you can select when you create a custom field.

For the example above, you would build the promotion by defining a Type called “Promotion” (or whatever you’d like to name it) with sub-fields like:

  1. “Name” of type single-line text
  2. “Photo” of type Photo
  3. “Description” of type multi-line text
  4. “URL” of type URL

promotion as custom field type

The actual subfields would depend on your brand and how you think about Promotions. Most brands define these differently, like some have availability dates while others don’t, or some have videos instead of photos, and so on. This is why you have the flexibility to define your own objects.

Once you define a new Custom Field Type, the type becomes selectable when you are creating a new Custom Field along with the Standard Types.

light bulb
Note
Want to nest a complex field within a field, like a CTA within a Promotion object? The easiest way is to use the “struct” field type, which allows you to define a nested object in-line (without having to save it as a type first). You can nest subfields in subfields in subfields - but, beware! The UI can start to get a bit hairy and uploading and exporting the data becomes more complicated. Only do this when you need to!

Common Examples of Custom Field Types

Here are some examples of custom field types that we’ve seen:

  • Size/Dimensions, e.g., Height, Length, Width subfields
  • Promotions, e.g., Photo, description, text, expiration date subfields
  • Product Availability, e.g., Location (linked entity), inventory, price subfields

How to Create a Custom Field Type

  1. Navigate to Content > Configuration > Field Types. Here’s where you can see any Custom Field Types you’ve already defined. Click “Add Custom Field Type” button to get started.

  2. Fill in the Name of the type. This will appear in the Add Custom Field page in the Type dropdown, as well as in the Custom Field table.

  3. Optionally, add a description so other users in the platform understand what it is or what you’re using it for.

  4. Click to add your subfields. For each subfield, you will need to define:

    • Subfield Type: You can select from any Standard or Custom Field Type defined in the account. You can also choose to create a “Struct” which allows you to define a nested object in-line (without having to save it as a type first).

    • Subfield Label: This is the subfield name users will see in Entity Edit.

    • Validation: Optionally, you can set subfield validation just like you can on a field. For example, if you have a CTA type, you might want to limit the CTA text character length depending on the button size on the page. You can only change type validation before the field is being used so make sure to think about this carefully.

    • Required Setting: If you check this box, this subfield will be required when users fill out the field. For example, if you have a Promotion custom type, you might make the Name and Description subfields required, but might leave the Photo optional depending on your brand’s preferences.

    • Make it a List: If you check this box, it will add this subfield as a list within the object. For example, you could have a list of URLs or photos.

  5. Once you’ve added and defined all of your subfields, click “Save”.

  6. Go to Content > Configuration > Fields to add a Custom Field instance of this type.

unit Quiz
+20 points
Daily Quiz Streak Daily Quiz Streak: 0
Quiz Accuracy Streak Quiz Accuracy Streak: 0
    Error Success Question 1 of 2

    Custom Field Types allow you to: (Select all that apply)

    Error Success Question 2 of 2

    True or False: When setting your subfield type, you can select from any Standard or Custom Field Type defined in the account.

    You're a star! ⭐

    You've already completed this quiz, so you can't earn more points.You completed this quiz in 1 attempt and earned 0 points! Feel free to review your answers and move on when you're ready.
1st attempt
0 incorrect
Feedback