UserFields
Returns user fields, including custom field type, validation, and relationship filter details.
Table-Specific Information
Select
The following query is processed server-side while other filters are processed client-side within the provider.SELECT * FROM UserFields WHERE Id = '123'
Insert
The Type, Title, and Key columns are required to insert. Types of custom fields that can be created are: text (default when no Type is specified), textarea, checkbox, tagger (dropdown), date, integer, decimal, and regex. When Type is regex, RegexpForValidation is also required. When Type is tagger, CustomFieldOptions is also required. This operation is allowed for logged-in users with the "admin" role only.
When creating a dropdown field, pass a null Id along with name and value for each new option.
INSERT INTO UserFields (Type, Title, Key) VALUES ('text', 'Support description', 'support_description')
INSERT INTO UserFields (Type, Title, Key, RegexpForValidation) VALUES ('regexp', 'TestRegExp', 'test_regexp', '\\b([0-9]{4})-(1[0-2]|0?[1-9])-(3[0-1]|[1-2][0-9]|0?[1-9])\\b')
INSERT INTO UserFields (Type, Title, Key, CustomFieldOptions) VALUES ('tagger', 'TestDropdown', 'test_dropdown', '[{"id": null, "name": "Option 1", "value": "option_1"}, {"id": null, "name": "Option 2", "value": "option_2"}, {"id": null, "name": "Option 3", "value": "option_3"}]')
Lookup Relationships
You can also create Lookup Relationships. A lookup relationship field is a custom field whose type is "lookup". This type of custom field gives you the ability to create a relationship from a source object to a target object.
To create lookup relationship fields, the Type, Key, and RelationshipTargetType columns are required. The Type column value must be "lookup". A suitable combination of Field, Operator, and Value is required for insertion in RelationshipFilterAll and RelationshipFilterAny. See a list of the possible combinations here.
INSERT INTO UserFieldsRelationshipFilterAll#temp(Field, Operator, Value) VALUES ('status', 'less_than', 'solved')
INSERT INTO UserFieldsRelationshipFilterAny#temp(Field, Operator, Value) VALUES ('status', 'less_than', 'solved')
INSERT INTO UserFields (Type, Title, Key, RelationshipTargetType, RelationshipFilterAll, RelationshipFilterAny) VALUES ('lookup', 'Support description', 'support_description5', 'zen:ticket', 'UserFieldsRelationshipFilterAll#temp', 'UserFieldsRelationshipFilterAny#temp')
Update
You must specify the Id of the ticket field to update. All fields that are not readonly are optional. This operation is allowed for logged-in users with the "admin" role only.
When updating a dropdown field, note the following:
- To update an existing option, pass its Id along with name and value.
- All options must be passed on update. Options that are not passed will be removed; as a result, these values will be removed from any users.
- To reorder an option, reposition it in the CustomFieldOptions array relative to the other options.
- To remove an option, omit it from the list of options upon update.
UPDATE UserFields SET Title = 'Support description' WHERE Id = '123'
For ticket fields of type tagger (dropdown) use the CustomFieldOptions column to update the options. For type regexp use RegexpForValidation to update the regular expression.
Delete
You must specify the Id of the user field to delete it. This operation is allowed for logged-in users with the "admin" role only.
DELETE FROM UserFields WHERE Id = '123'
Columns
| Name | Type | ReadOnly | References | Description |
| Id [KEY] | Long | True |
The Id of the user field, automatically assigned upon creation. | |
| Key | String | False |
A unique key that identifies this custom field. Required on create. This is used for updating the field and referencing in placeholders. After a field is created, you cannot change its key. | |
| Type | String | False |
Type of the custom field: checkbox, date, decimal, dropdown, integer, regexp, text, or textarea. After a field is created, you cannot change its type. | |
| Title | String | False |
The title of the custom field. | |
| RawTitle | String | False |
The dynamic content placeholder, if present, or the title value, if not. | |
| Description | String | False |
User-defined description of this field's purpose. | |
| RawDescription | String | False |
The dynamic content placeholder, if present, or the description value, if not. | |
| Position | Integer | False |
Ordering of the field relative to other fields. | |
| Active | Boolean | False |
Indicates whether this field is available for use. | |
| System | Boolean | True |
Indicates whether only the active and position values of this field can be changed. | |
| RegexpForValidation | String | False |
Regular expression field only. The validation pattern for a field value to be deemed valid. | |
| CreatedAt | Datetime | True |
The date and time the user field was created. | |
| UpdatedAt | Datetime | True |
The date and time the user field was last updated. | |
| Tag | String | False |
Optional for custom field of type checkbox; not presented otherwise. | |
| CustomFieldOptions | String | False |
Required and presented for a custom field of type dropdown. | |
| Url | String | True |
The URL for this resource. | |
| RelationshipTargetType | String | False |
A representation of what type of object the field references. Options are zen:user, zen:organization, zen:ticket, and zen:custom_object:CUSTOM_OBJECT_KEY. For example: zen:custom_object:apartment. | |
| RelationshipFilterAll | String | False |
A filter definition that filters autocomplete results using a logical AND condition. | |
| RelationshipFilterAny | String | False |
A filter definition that filters autocomplete results using a logical OR condition. |