Custom Fields
Set values for Custom Fields defined by Types.
This page documents the value representations of your self-defined project-specific fields, called Custom Fields, which you have on resources and data types that you have customized using Types.
Custom Fields can be set or unset
- with the resource or object draft during creation of a customizable data type, or
- with Set CustomField update actions provided for each customizable data type.
Find the documentation for the drafts and the update actions in the respective API reference docs for the customized resource or data type.
Custom Fields are queryable and sortable. ReferenceType Custom Fields are expandable.
To get notified when the Custom Fields on a resource are updated, create a ChangeSubscription that subscribes to changes on that resource (for example, to Customer
).
Representations
CustomFields
When using Custom Fields with GraphQL API mutations, you must stringify all values in the value
field: "value" : "\"A string value\""
.
The value
field exists only in the GraphQL API, and not in the HTTP API.
Serves as value of the custom
field on a resource or data type customized with a Type.
type | Reference to the Type that holds the FieldDefinitions for the Custom Fields. |
fields | Object containing the Custom Fields for the customized resource or data type. |
{"type": {"id": "ff8b0f8c-78c8-4c4c-a4b7-2545d9279515","typeId": "type"},"fields": {"exampleStringField": "The value of this Custom Field."}}
CustomFieldsDraft
The representation used when creating or updating a customizable data type with Custom Fields.
type |
|
fields | Object containing the Custom Fields for the customized resource or data type. |
{"type": {"key": "key-of-type","typeId": "type"},"fields": {"exampleStringField": "The value of this Custom Field."}}
FieldContainer
A JSON object containing key-value pairs.
- key is the
name
of the Custom Field, as defined in the respective FieldDefinition. - value is the CustomFieldValue compliant to the respective FieldType.
Find below an example FieldContainer with CustomFieldValues of several FieldTypes:
{"exampleBooleanField": true,"exampleSetOfBooleanField": [true, false, true],"exampleStringField": "Any String value","exampleSetOfStringField": ["Some String value", "Another String value"],"exampleLocalizedStringField": {"en": "English text","es": "texto en español"},"exampleSetOfLocalizedStringField": [{"en": "English text 1","es": "texto en español 1"},{"en": "English text 2","es": "texto en español 2"}],"exampleEnumField": "enum key defined in FieldDefinition","exampleSetOfEnumField": ["enum key defined in FieldDefinition-1","enum key defined in FieldDefinition-2"],"exampleLocalizedEnumField": "enum key defined in FieldDefinition","exampleSetOfLocalizedEnumField": ["enum key defined in FieldDefinition-1","enum key defined in FieldDefinition-2"],"exampleNumberField": 42,"exampleSetOfNumberField": [1, 2, 7],"exampleMoneyField": {"type": "centPrecision","currencyCode": "USD","centAmount": 124500,"fractionDigits": 2},"exampleSetOfMoneyField": [{"type": "centPrecision","currencyCode": "USD","centAmount": 124500,"fractionDigits": 2},{"type": "centPrecision","currencyCode": "USD","centAmount": 1000,"fractionDigits": 2}],"exampleDateField": "2001-10-12","exampleSetOfDateField": ["2001-10-12", "2015-03-14", "2003-05-15"],"exampleTimeField": "14:00:00.000","exampleSetOfTimeField": ["14:00:00.000", "14:30:00.000"],"exampleDatetimeField": "2018-10-14T14:00:00.000Z","exampleSetOfDatetimeField": ["2018-10-14T14:00:00.000Z"],"exampleReferenceField": {"typeId": "product","id": "d1229e6f-2b79-441e-b419-180311e52754"},"exampleSetOfReferenceField": [{"typeId": "product","id": "d1229e6f-2b79-441e-b419-180311e52754"},{"typeId": "product","id": "e1549e6f-3b79-441e-c486-957480r23744"}]}
CustomFieldValue
The value of a Custom Field.
The data type of the value depends on the specific FieldType given in the type
field of the FieldDefinition for a Custom Field.
It can be any of the following:
Field type | Data type |
---|---|
CustomFieldBooleanType | Boolean (true or false ) |
CustomFieldNumberType | Number |
CustomFieldStringType | String |
CustomFieldLocalizedStringType | LocalizedString |
CustomFieldEnumType | String. Must be a key of one of the EnumValues defined in the EnumType |
CustomFieldLocalizedEnumType | String. Must be a key of one of the LocalizedEnumValues defined in the LocalizedEnumType |
CustomFieldMoneyType | CentPrecisionMoney |
CustomFieldDateType | Date |
CustomFieldTimeType | Time |
CustomFieldDateTimeType | DateTime |
CustomFieldReferenceType | Reference |
CustomFieldSetType | JSON array without duplicates consisting of CustomFieldValues of a single FieldType. For example, a Custom Field of CustomFieldSetType of CustomFieldDateType takes a JSON array of mutually different Dates for its value. The order of items in the array is not fixed. For more examples, see the example FieldContainer. |