Configure Custom Fields for Users
    • Dark
      Light
    • PDF

    Configure Custom Fields for Users

    • Dark
      Light
    • PDF

    Article summary

    You can set custom fields for specific users while registering or updating the user information. For example, you can add fields like address or employee ID.

    Note: Currently, you may need some basic understanding of Javascript and Rocket.Chat's internal working structure to set other custom fields than 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 any 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: select and text, where select creates a drop-down list, and text creates a plain text form. If you enter a URL in the text field, it is interpreted as a hyperlink (it will be clickable on the User Info pane).

    defaultValue

    Used with a select form type to set the default option for the list.

    options

    Used with a select form type for the values that should be on the drop-down list, which follows the ["item1", "item2","item3"] pattern. Use a JavaScript Array to create it.

    required

    Set whether the field is required for registration. Enter true or false for this property.

    minLength

    Used with the text type to define the minimum length required for the text.

    maxLength

    Used with the text type to define the maximum length required for the text.

    modifyRecordField

    This property is required when you add a field that already exists in Rocket.Chat.

    array

    Used inside the modifyRecordField property to define whether the existing field is an array.

    field

    Used inside the modifyRecordField property. It should be the name of the existing field.

    public

    Defines the field as visible to other users when viewing the user's profile. Enter true or false for this property. By default, the value is true.

    private

    Defines the field as private. Only users with view-full-other-user-info permission can see this field when viewing the user's profile. Enter true or false for this property.

    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 that are 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, the fields will be displayed when creating new users, or updating existing ones. Enter the respective values and save the user details.


    Was this article helpful?

    What's Next
    ESC

    Eddy AI, facilitating knowledge discovery through conversational intelligence