When querying data via the Calendar API, custom fields can be accessed through their entity associations. However, the values will be returned as a separate element for each custom field value that is associated to the parent entity.
These will return all of the room custom field names and values associated with the activity. If there is more than a single custom field, the activity will be returned for each of them with all data repeated other than the custom field information. This is due to the one-to-many nature of the association and is the same as with multiple resources returned via the Calendar API.
Example of full call:
The Query API is often the cleanest way to get the custom field information in bulk. When searching for the List Values or the list of custom field names associated to a specific entity, the Query API will return them in a clean list.
If using the Query API to directly call an activity and making the associations, the results will return multiple elements with the non-custom field data being repeated (as with the Calendar API). Again, this is due to the one-to-many nature of these associations.
Examples of these calls via a debugger tool can be captured by going to the Settings > Custom Fields page. When the page drop-down is selected, the query call to the UserFieldDefinition can be seen:
When the custom field information of a single item is needed, the Entity API can be used to pull the custom field data for that specific item. A single event meeting, event, or section can be returned this way:
This will return both the title and the value associated for the specific item referenced in the call. When the value returned is a GUID, this means that the UserFieldListValues must be checked to return the name of the value selected.
The custom field data model can be challenging. There are multiple entities that tie together and may be used to get the association to the parent entity to the value that is displayed. The model representation below is the basic structure of the associations.
Custom Field Entities:
UserFieldOwner - Indicates the element with which the custom field is associated (Room, Building, Section, Event, etc.)
Fields: Id, TableName, DisplayName
UserFieldDefinition – The parent custom field information. Link between the owner and the value.
Fields: Id, Name, OwnerId, DisplayLabel, FieldTypeCode, ControlTypeCode, IsReqired, IsReadOnly
Common Filter: OwnerId.
UserFieldValue – The actual value saved into the custom field.
Fields: Id, RecordId, TableName, Value
Common Filter: UserFieldDefinitionId
UserFieldListValue – Values that can be found in the drop-down list custom fields. Must be pulled separately and used via lookup. ID in UserFieldValue is ID of the ListValue, but there is no direct entity association.
Fields: Id, UserFieldDefinitionId, Name, Value
Common Filter: ID