Add Custom Field userfieldconfig.add
Scope:
userfieldconfig, module scope frommoduleId(for example,crm)Who can execute the method: a user with permission to modify object settings in the
moduleId(forcrm— permission "Allow to modify settings")
The method userfieldconfig.add adds a new custom field.
Method Parameters
Required parameters are marked with *
|
Name |
Description |
|
moduleId* |
Identifier of the module where the field is created |
|
field* |
Object with custom field settings (detailed description) |
Parameter field
|
Name |
Description |
|
entityId* |
Identifier of the object for which the field is created. The format depends on the module, for example, |
|
fieldName* |
Field code in the format |
|
userTypeId* |
Identifier of the field type. The list of available types is returned by the method userfieldconfig.getTypes |
|
xmlId |
External identifier of the field |
|
sort |
Sort index. Default is |
|
multiple |
Indicates whether the field is multiple. Possible values: |
|
mandatory |
Indicates whether the field is mandatory. Possible values: |
|
showFilter |
Whether to show the field in the filter. Possible values: |
|
editInList |
Whether to allow editing the value in the list. Possible values: |
|
isSearchable |
Whether the field values are included in the search. Possible values: |
|
settings |
Additional settings for the field. The set of keys depends on |
|
Label in the edit form. When a string is passed, it is used as a general value; when |
|
|
Help text. When a string is passed, it is used as a general value; when |
|
|
enum |
Value options for fields of type |
The method uses a fixed set of keys in field (see the table above).
Incorrect and unsupported keys in field are ignored.
The keys showInList, listColumnLabel, listFilterLabel, errorMessage, label are not processed by the method userfieldconfig.add, even if passed in field.
Parameter settings
Each field type has its own set of keys in settings.
|
Name |
Description |
|
DEFAULT_VALUE |
Default value |
|
ROWS |
Number of rows in the input field, must be greater than 0 |
|
SIZE |
Width of the input field |
|
REGEXP |
Regular expression for validation |
|
MIN_LENGTH |
Minimum length of the string |
|
MAX_LENGTH |
Maximum length of the string |
|
Name |
Description |
|
DEFAULT_VALUE |
Default value |
|
SIZE |
Width of the input field |
|
MIN_VALUE |
Minimum value |
|
MAX_VALUE |
Maximum value |
|
Name |
Description |
|
DEFAULT_VALUE |
Default value |
|
PRECISION |
Precision of the number, must be greater than or equal to 0 |
|
SIZE |
Width of the input field |
|
MIN_VALUE |
Minimum value |
|
MAX_VALUE |
Maximum value |
|
Name |
Description |
|
DEFAULT_VALUE |
Default value, where |
|
DISPLAY |
Appearance, possible values: |
|
LABEL |
Label for the Yes value |
|
LABEL_CHECKBOX |
Label for |
|
Name |
Description |
|
DEFAULT_VALUE |
Default value in the format |
|
USE_SECOND |
Use seconds in the |
|
USE_TIMEZONE |
Use timezone in the |
|
Name |
Description |
|
|
DEFAULT_VALUE |
Default value in the format ` |
{CURRENCY}` |
|
Name |
Description |
|
POPUP |
Open link in a new window |
|
SIZE |
Width of the input field |
|
MIN_LENGTH |
Minimum length of the value |
|
MAX_LENGTH |
Maximum length of the value |
|
DEFAULT_VALUE |
Default value |
|
ROWS |
Number of rows in the input field |
|
Name |
Description |
|
SHOW_MAP |
Show map for the address |
|
Name |
Description |
|
SIZE |
Width of the input field |
|
LIST_WIDTH |
Width of the preview in the list |
|
LIST_HEIGHT |
Height of the preview in the list |
|
MAX_SHOW_SIZE |
Maximum file size for display |
|
MAX_ALLOWED_SIZE |
Maximum allowed file size |
|
EXTENSIONS |
List of allowed extensions |
|
TARGET_BLANK |
Open file in a new tab |
|
Name |
Description |
|
DISPLAY |
Appearance, possible values: |
|
LIST_HEIGHT |
Height of the list, must be greater than 0 |
|
CAPTION_NO_VALUE |
Label for empty value |
|
SHOW_NO_VALUE |
Show empty value |
|
Name |
Description |
|
DISPLAY |
Appearance, possible values: |
|
LIST_HEIGHT |
Height of the list, must be greater than 0 |
|
IBLOCK_ID |
Identifier of the information block |
|
DEFAULT_VALUE |
Default value |
|
ACTIVE_FILTER |
Use only active elements |
|
Name |
Description |
|
ENTITY_TYPE |
Identifier of the CRM reference type. Possible values can be obtained by the method |
|
Name |
Description |
|
LEAD |
Enable binding to leads |
|
CONTACT |
Enable binding to contacts |
|
COMPANY |
Enable binding to companies |
|
DEAL |
Enable binding to deals |
|
QUOTE |
Enable binding to estimates |
|
ORDER |
Enable binding to orders |
|
SMART_INVOICE |
Enable binding to invoices |
|
DYNAMIC_* |
Enable binding to SPA with a specific |
Separate settings in settings for the employee type are not used.
Settings are defined by the handler of the custom field type.
Type uf_enum_element
|
Name |
Description |
|
value* |
Value of the list option |
|
def |
Default value flag ( |
|
sort |
Sort index of the option |
|
xmlId |
External identifier of the option |
Code Examples
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"moduleId": "crm",
"field": {
"entityId": "CRM_7",
"fieldName": "UF_CRM_7_NEW_REST_LIST_2026",
"userTypeId": "enumeration",
"multiple": "Y",
"editFormLabel": {
"en": "List of characteristics"
},
"enum": [
{ "value": "Characteristic 1", "def": "N", "sort": 100 },
{ "value": "Characteristic 2", "def": "Y", "sort": 200 }
]
}
}' \
"https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/userfieldconfig.add"
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"moduleId": "crm",
"field": {
"entityId": "CRM_7",
"fieldName": "UF_CRM_7_NEW_REST_LIST_2026",
"userTypeId": "enumeration",
"multiple": "Y",
"editFormLabel": {
"en": "List of characteristics"
},
"enum": [
{ "value": "Characteristic 1", "def": "N", "sort": 100 },
{ "value": "Characteristic 2", "def": "Y", "sort": 200 }
]
},
"auth": "**put_access_token_here**"
}' \
"https://**put_your_bitrix24_address**/rest/userfieldconfig.add"
const endpoint = "https://**put_your_bitrix24_address**/rest/userfieldconfig.add.json";
fetch(endpoint, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
auth: "**put_access_token_here**",
moduleId: "crm",
field: {
entityId: "CRM_7",
fieldName: "UF_CRM_7_NEW_REST_LIST_2026",
userTypeId: "enumeration",
multiple: "Y",
editFormLabel: {
en: "List of characteristics",
},
enum: [
{ value: "Characteristic 1", def: "N", sort: 100 },
{ value: "Characteristic 2", def: "Y", sort: 200 },
],
},
}),
})
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.error(error));
$payload = [
'auth' => '**put_access_token_here**',
'moduleId' => 'crm',
'field' => [
'entityId' => 'CRM_7',
'fieldName' => 'UF_CRM_7_NEW_REST_LIST_2026',
'userTypeId' => 'enumeration',
'multiple' => 'Y',
'editFormLabel' => [
'en' => 'List of characteristics',
],
'enum' => [
['value' => 'Characteristic 1', 'def' => 'N', 'sort' => 100],
['value' => 'Characteristic 2', 'def' => 'Y', 'sort' => 200],
],
],
];
$curl = curl_init('https://**put_your_bitrix24_address**/rest/userfieldconfig.add.json');
curl_setopt_array($curl, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$result = curl_exec($curl);
curl_close($curl);
print_r($result);
BX24.callMethod(
"userfieldconfig.add",
{
moduleId: "crm",
field: {
entityId: "CRM_7",
fieldName: "UF_CRM_7_NEW_REST_LIST_2026",
userTypeId: "enumeration",
multiple: "Y",
editFormLabel: {
en: "List of characteristics",
},
enum: [
{ value: "Characteristic 1", def: "N", sort: 100 },
{ value: "Characteristic 2", def: "Y", sort: 200 },
],
},
},
(result) => {
if (result.error()) {
console.error(result.error());
} else {
console.info(result.data());
}
}
);
require_once('crest.php');
$result = CRest::call(
'userfieldconfig.add',
[
'moduleId' => 'crm',
'field' => [
'entityId' => 'CRM_7',
'fieldName' => 'UF_CRM_7_NEW_REST_LIST_2026',
'userTypeId' => 'enumeration',
'multiple' => 'Y',
'editFormLabel' => [
'en' => 'List of characteristics',
],
'enum' => [
['value' => 'Characteristic 1', 'def' => 'N', 'sort' => 100],
['value' => 'Characteristic 2', 'def' => 'Y', 'sort' => 200],
],
],
]
);
echo '<pre>';
print_r($result);
echo '</pre>';
Response Handling
HTTP Status: 200
{
"result": {
"field": {
"id": "6953",
"entityId": "CRM_7",
"fieldName": "UF_CRM_7_NEW_REST_LIST_2026",
"userTypeId": "enumeration",
"xmlId": null,
"sort": "100",
"multiple": "Y",
"mandatory": "N",
"showFilter": "N",
"showInList": "Y",
"editInList": "Y",
"isSearchable": "N",
"settings": {
"DISPLAY": "LIST",
"LIST_HEIGHT": 1,
"CAPTION_NO_VALUE": "",
"SHOW_NO_VALUE": "Y"
},
"languageId": {
"en": "en"
},
"editFormLabel": {
"en": "List of characteristics"
},
"listColumnLabel": {
"en": null
},
"listFilterLabel": {
"en": null
},
"errorMessage": {
"en": null
},
"helpMessage": {
"en": null
},
"enum": [
{
"id": "3363",
"userFieldId": "6953",
"value": "Characteristic 1",
"def": "N",
"sort": "100",
"xmlId": "56dff18efcfe25f3bae0117a6b372567"
},
{
"id": "3365",
"userFieldId": "6953",
"value": "Characteristic 2",
"def": "Y",
"sort": "200",
"xmlId": "42e3ebcf5506a65283bf3bf510d8f05a"
}
]
}
},
"time": {
"start": 1724239307.903115,
"finish": 1724239308.567422,
"duration": 0.6643068790435791,
"processing": 0.20090818405151367,
"date_start": "2024-08-21T13:21:47+02:00",
"date_finish": "2024-08-21T13:21:48+02:00",
"operating": 0
}
}
Returned Data
|
Name |
Description |
|
result |
Root element of the response (detailed description) |
|
time |
Information about the request execution time |
Object result
|
Name |
Description |
|
field |
Settings of the created custom field (detailed description) |
Object field
|
Name |
Description |
|
id |
Identifier of the field settings |
|
entityId |
Identifier of the object |
|
fieldName |
Field code |
|
userTypeId |
Identifier of the field type |
|
xmlId |
External identifier of the field |
|
sort |
Sort index |
|
multiple |
Multiple value flag ( |
|
mandatory |
Mandatory field flag ( |
|
showFilter |
Flag to show the field in the filter |
|
showInList |
Flag to show the field in the list |
|
editInList |
Flag for editing in the list |
|
isSearchable |
Flag for participation in search |
|
settings |
Additional settings for the field (detailed description). The set of keys depends on |
|
languageId |
Languages for which field labels are set |
|
editFormLabel |
Labels in the edit form |
|
listColumnLabel |
Column labels in the list |
|
listFilterLabel |
Filter labels |
|
errorMessage |
Error message text |
|
helpMessage |
Help text for the field |
|
enum |
Value options. This field is returned only for |
Error Handling
HTTP Status: 400
{
"error": "",
"error_description": "The 'FIELD_NAME' field is not found."
}
|
Name |
Description |
|
error |
String error code. It may consist of digits, Latin letters, and underscores |
|
error_description |
Textual description of the error. The description is not intended to be shown to the end user in its raw form |
Possible Error Codes
|
Code |
Description |
Value |
|
|
Access denied |
Insufficient permissions to create a custom field |
|
|
You cannot create custom fields |
This error may occur if |
|
|
The 'USER_TYPE_ID' field is not found |
Required |
|
|
The 'FIELD_NAME' field is not found |
Required |
|
|
Field ... already exists |
The provided |
|
|
Fail to create new user field |
Error creating the field on the server side |
|
|
Fail to save enumeration field values |
Error saving list values for type |
Statuses and System Error Codes
HTTP Status: 20x, 40x, 50x
The errors described below may occur when calling any method.
|
Status |
Code |
Description |
|
|
|
An internal server error has occurred. Please contact the server administrator or Bitrix24 technical support |
|
|
|
An internal server error has occurred. Please contact the server administrator or Bitrix24 technical support |
|
|
|
The request intensity limit has been exceeded |
|
|
|
The current method is not permitted for calls using batch |
|
|
|
The maximum length of parameters passed to the batch method has been exceeded |
|
|
|
Invalid access token or webhook code |
|
|
|
The HTTPS protocol is required for method calls |
|
|
|
The REST API is blocked due to overload. This is a manual individual block; please contact Bitrix24 technical support to lift it |
|
|
|
The REST API is only available on commercial plans |
|
|
|
The user associated with the access token or webhook used to call the method lacks the necessary permissions |
|
|
|
The manifest is not available |
|
|
|
The request requires higher privileges than those provided by the webhook token |
|
|
|
The provided access token has expired |
|
|
|
The user does not have access to the application. This means that the application is installed, but the portal administrator has restricted access to this application to specific users only |
|
|
|
The public part of the site is closed. To open the public part of the site on an on-premise installation, disable the "Temporary closure of the public part of the site" option. Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site |
Continue Learning
- Update User Field userfieldconfig.update
- Get User Field Settings userfieldconfig.get
- Get a List of User Field Settings userfieldconfig.list
- Delete Custom Field userfieldconfig.delete
- Get Available User Field Types userfieldconfig.getTypes