Set additional field values for Contentful
Learn how you can set additional field values when exporting content from Google Docs or Notion to Contentful.
Introduction
Cloudpress allows you to set additional field values when exporting content to Contentful. This document gives you more information on the Contentful field support in Cloudpress.
Please refer to the Export additional fields to your CMS documentation for information on specifying the values when exporting from Google Docs and Notion.
Field names
When updating additional field values during export, you will need to specify the name of a field in Contentful for which you want to set a value. The field name you supply to Cloudpress must be the Field ID for a field in your Content model in Contentful. Open the definition of the relevant Content model in Contentful, and click on the Edit link next to the field.
The Field ID is displayed on the field settings dialog. The correct name you must use in the example below will be slug
.
Field types and allowed values
When you create a field in Contentful, you need to specify the field type. The field type can be seen on the Content model, next to the name of the field:
Cloudpress supports updating values for the following field types:
Field type | Allowed values |
---|---|
Short text | Any text value |
Long text | Any text value |
Integer | A text value representing a number, e.g. 123 |
Decimal | A text value representing a decimal, e.g. 1.23 |
Date & Time | A text value representing a date in https://en.wikipedia.org/wiki/ISO_8601, e.g. 2022-09-24T09:24:53 |
Boolean | A text value represents a boolean value. The value must be either true or false |
Short text, list | A text value representing a single item (e.g. Travel) or a list of items, delimited by a semicolon (;), e.g. Travel; Shopping. |
Reference | A text value with the id of the referenced entry. If the field is configured with a validation rule that limits the referenced entry to specific entry types, you can also use the title of the referenced entry. See more detail below. |
References, many | A text value with the id of the referenced entry. You can use a semicolon (;) to separate multiple entries, e.g. Category 1; Category 2. If the field is configured with a validation rule that limits the referenced entry to specific entry types, you can also use the title of the referenced entry. See more detail below. |
Media | An image value |
Non-supported field types
Currently, Cloudpress does not support updating ”Rich text” and ”Media, many files” field types.
Working with referenced entries
As mentioned above, when working with the Reference and References, many field types, you can use either the id
of referenced entry or the title of the referenced entry. Let’s look at these in more detail.
“Reference” field type
Suppose we have a “Blog Post” model that is defined as follows:
Note that we have an “Author” field configured as a Reference field. Drilling into the settings of this field, you can notice that the field is configured with a validation rule that limits the references entry to Authors.
Now, let’s look at the Author model. You can see that the model has Name field configured as the entry title.
In this case, when updating the author
field in the Blog Post, the value can be either the id
or name
of an author.
For example, let’s say we have the following author entries in Contentful.
Id | Name |
---|---|
2h06k81RVAAI9R0N6GsbWF | Peter Parker |
pqI6NaSl9sW6bOr3fZzNM | James Earl Jones |
If you want to set the author to Peter Parker, you can set the value for the author
field to either 2h06k81RVAAI9R0N6GsbWF
or Peter Parker
.
“References, many” field type
The “References, many” field type works similar to the normal “Reference” field type discussed above, except that you can set the value to multiple entries by separating them with a semicolon (;
).
Let’s look at our “Blog Post” model from before:
Note that we have a “Categories” field configured as a “References, many” field. Drilling into the settings of this field, you can notice that the field is configured with a validation rule that limits the references entry to Categories.
Now, let’s look at the “Category” model. You can see that the model has a “Name” field configured as the entry title.
In this case, when updating the categories
field in the “Blog Post”, the value can be either the id
or name
of a category.
For example, let’s say we have the following category entries in Contentful.
Id | Name |
---|---|
l6sfqcZGhxgREl9UB0cKo | Travel |
6doYzrj2D79n6tYJ2lsOZd | Asia |
If you want to set the categories
field to “Travel”, you can set the value to either l6sfqcZGhxgREl9UB0cKo
or Travel
. If you want to set the categories
field to both categories, you can set the value to either l6sfqcZGhxgREl9UB0cKo; 6doYzrj2D79n6tYJ2lsOZd
, or Travel; Asia
.
You can even mix the use of id
and name
. For example, you can set the value to l6sfqcZGhxgREl9UB0cKo; Asia
, which will assign both categories to the field.