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.
You may need some basic understanding of Javascript and Rocket.Chat's internal working structure is required to set other custom fields than those in the example below. A more user-friendly interface is planned for the future.
Define custom fields
To set custom fields, go to Administration > Workspace > Settings > Accounts > Registration > Custom Fields. Configure the custom fields using a JSON object containing a dictionary of field settings. Let's look at two examples.
Basic example
In this example, we add 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"
}
}
Once these custom fields are saved, you can enter the values for the fields while creating a new user or updating an existing user. The following screenshot shows the example:
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
}
}
Let's look at the properties in detail:
Parameter | Description |
---|---|
type | Defines the type of the custom field. Currently, there are 2 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 | Define 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 Administration > Workspace > Settings > Accounts > Custom Fields to Show in User Info.
The list of fields needs to be specified as a JSON array in the following format:
[{"label1":"key2"},{"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. Considering the previous example, the field can look something like this:
[{"Role":"role"},{"Department":"dept"}]
This means that the role
and dept
custom fields will be displayed on the User Info panel. Note that the fields are only shown if the user has permission to view private fields or if the field is set to "public": true
.
Set custom field values
Now that you have configured the custom fields, they will be displayed when creating new users or updating existing ones. Enter the respective values and save the user details.