You can set custom fields for specific users while registering or updating user information. For example, you can add fields like address or employee ID.
To define fields other than those in the examples, you need a basic understanding of JSON and how Rocket.Chat stores user data.
Define custom fields
To set custom fields, go to Manage → Workspace → Settings → Accounts → Registration → Custom Fields. Configure the custom fields using a JSON object containing a dictionary of field settings. The setting provides a code editor with line numbers. Click Full Screen to expand the editor while working with larger configurations.
Basic example
This example adds two custom fields, team and designation, with the type text. This means that the custom fields can take any text values as input.
{
"team": {
"type": "text"
},
"designation": {
"type": "text"
}
}Custom field keys are case-sensitive. The key you define here (for example,
team) is the exact name you must use everywhere the field is referenced, such as in Custom Fields to Show in User Info or via the API.
After you save the custom fields, they appear when you create a new user or update an existing one, as shown in the following screenshot:
.png)
Advanced example
Here, role is a custom field consisting of two options (teacher and student) as the possible values. twitter and dept are text fields where you can enter values according to the defined settings.
{
"role": {
"type": "select",
"defaultValue": "student",
"options": ["teacher", "student"],
"required": true,
"modifyRecordField": {
"array": true,
"field": "roles"
}
},
"twitter": {
"type": "text",
"required": true,
"minLength": 2,
"maxLength": 10
},
"dept": {
"type": "text",
"required": false,
"minLength": 12,
"sendToIntegrations": true
}
}The following table describes each property:
Parameter | Description |
|---|---|
type | Defines the type of the custom field. There are two types: |
defaultValue | Used with a |
options | Used with a |
required | Set whether the field is required for registration. Enter |
minLength | Used with the |
maxLength | Used with the |
modifyRecordField | This property is required when you add a field that already exists in Rocket.Chat.
|
array | Used inside the |
field | Used inside the |
public | Defines the field as visible to other users when viewing the user's profile. Enter |
private | Defines the field as private. Only users with |
sendToIntegrations | Defines the field as shareable with external applications, such as Omnichannel integrations. |
Use tabs for indentation in the JSON object, do not use spaces.
You can also use the API to create and manage custom fields. See the Create User, Update User, and Get Users List endpoints.
Display user’s custom fields
You can configure the list of custom fields displayed on the User Info panel. Go to Manage → Workspace → Settings → Accounts → Custom Fields to Show in User Info.
The value must be a JSON array of objects, where each object's key is the label shown to users and its value is the custom field name defined previously:
[{"label1":"key1"},{"label2":"key2"},...]The label can be the name of the custom field that is displayed for users. The key must be a custom field name defined previously. Based on the advanced example, the field can look like this:
[{"Role":"role"},{"Department":"dept"}]This means that the role and dept custom fields are displayed on the User Info panel with the labels Role and Department. A field is shown only if it is set to "public": true or if the viewer has permission to view private fields.
Set custom field values
To enter values for the custom fields, create a new user or edit an existing one, fill in the fields, and save. For instructions, see Manage Workspace Users.
Next steps
To set rules for message editing, deleting, and link previews, see Message Settings.