About Setting Custom Fields with the Event Management API
You can set values for custom fields when creating or updating events using the Event Management API.
If your site has custom fields defined for events, you can use the Event Management API to set values for these fields when creating or updating events. You must have the following information to set the value of a custom field:
-
the field ID (fieldId)
-
the field data type (fieldDataType)
You can obtain this information by using the GET /events/{eventId} endpoint to get event details for an event that contains the custom field. The response contains a sourcingProjectCustomFields array, with an entry for each custom field. For example:
"sourcingProjectCustomFields": [ { "fieldId": "cus_MyTextField", "fieldName": "My Text Field", "fieldDataType": "textValue", "textValue": [ null ], "templateProperties": [ "String1000Field", "DefaultDocumentField" ], "visibilityConstraint": { "expression": null, ... }, "editabilityConstraint": { "expression": null, ... }, "validityConstraint": { "expression": null, ... }, "customField": true } ], ...
Each entry for a custom field contains visibilityConstraint, editabilityConstraint, validityConstraint fields, which each contain an expression field. Each expression field can specify an expression that must be true for the field to be visible, editable, or valid. If an expression is null, there is no requirement (the custom field is always visible, editable, or valid).
-
fieldId
-
A data value; the key name is listed in the fieldDataType field. In the previous example, the fieldDataType value is textValue, so a textValue key is used to specify the field value.
-
"customField": true
For example, to set the value for My Text Field to hello, world, a POST /events or PUT /events request body would include the following:
"title": "My event",
...
"sourcingProjectCustomFields": [
{
"fieldId": "cus_MyTextField",
"fieldName": "My Text Field",
"fieldDataType": "textValue",
"textValue": [
"hello, world"
],
...
"customField": true
} ],
...