Get Custom Contact Field by Id crm.contact.userfield.get

Scope: crm

Who can execute the method: administrator

The method crm.contact.userfield.get returns a custom contact field by its identifier.

Method Parameters

Required parameters are marked with *

Name
type

Description

id*
integer

Identifier of the custom field associated with the contact.

The identifier can be obtained using the methods crm.contact.userfield.add or crm.contact.userfield.list

Code Examples

How to Use Examples in Documentation

Get the custom field with id = 399

curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"id":399}' \
        https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.contact.userfield.get
        
curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"id":399,"auth":"**put_access_token_here**"}' \
        https://**put_your_bitrix24_address**/rest/crm.contact.userfield.get
        
try
        {
        	const response = await $b24.callMethod(
        		'crm.contact.userfield.get',
        		{
        			id: 399,
        		}
        	);
        	
        	const result = response.getData().result;
        	result.error()
        		? console.error(result.error())
        		: console.info(result)
        	;
        }
        catch( error )
        {
        	console.error('Error:', error);
        }
        
try {
            $response = $b24Service
                ->core
                ->call(
                    'crm.contact.userfield.get',
                    [
                        'id' => 399,
                    ]
                );
        
            $result = $response
                ->getResponseData()
                ->getResult();
        
            if ($result->error()) {
                echo 'Error: ' . $result->error();
            } else {
                echo 'Data: ' . print_r($result->data(), true);
            }
        
        } catch (Throwable $e) {
            error_log($e->getMessage());
            echo 'Error getting contact user field: ' . $e->getMessage();
        }
        
BX24.callMethod(
            'crm.contact.userfield.get',
            {
                id: 399,
            },
            (result) => {
                result.error()
                    ? console.error(result.error())
                    : console.info(result.data())
                ;
            },
        );
        
require_once('crest.php');
        
        $result = CRest::call(
            'crm.contact.userfield.get',
            [
                'id' => 399
            ]
        );
        
        echo '<PRE>';
        print_r($result);
        echo '</PRE>';
        

Response Handling

HTTP Status: 200

{
            "result": {
                "ID": "399",
                "ENTITY_ID": "CRM_CONTACT",
                "FIELD_NAME": "UF_CRM_HELLO_WORLD",
                "USER_TYPE_ID": "string",
                "XML_ID": null,
                "SORT": "1000",
                "MULTIPLE": "Y",
                "MANDATORY": "Y",
                "SHOW_FILTER": "E",
                "SHOW_IN_LIST": "Y",
                "EDIT_IN_LIST": "Y",
                "IS_SEARCHABLE": "Y",
                "SETTINGS": {
                    "SIZE": 20,
                    "ROWS": 3,
                    "REGEXP": "",
                    "MIN_LENGTH": 0,
                    "MAX_LENGTH": 0,
                    "DEFAULT_VALUE": "Hello, World! Default value"
                },
                "EDIT_FORM_LABEL": {
                    "ar": "Field \u0027Hello, World!\u0027",
                    "br": "Field \u0027Hello, World!\u0027",
                    "en": "Hello, World! Edit",
                    "fr": "Field \u0027Hello, World!\u0027",
                    "id": "Field \u0027Hello, World!\u0027",
                    "it": "Field \u0027Hello, World!\u0027",
                    "ja": "Field \u0027Hello, World!\u0027",
                    "la": "Field \u0027Hello, World!\u0027",
                    "ms": "Field \u0027Hello, World!\u0027",
                    "pl": "Field \u0027Hello, World!\u0027",
                    "ru": "Hello, World! Edit",
                    "sc": "Field \u0027Hello, World!\u0027",
                    "tc": "Field \u0027Hello, World!\u0027",
                    "th": "Field \u0027Hello, World!\u0027",
                    "tr": "Field \u0027Hello, World!\u0027",
                    "vn": "Field \u0027Hello, World!\u0027"
                },
                "LIST_COLUMN_LABEL": {
                    "ar": "Field \u0027Hello, World!\u0027",
                    "br": "Field \u0027Hello, World!\u0027",
                    "en": "Hello, World! Column",
                    "fr": "Field \u0027Hello, World!\u0027",
                    "id": "Field \u0027Hello, World!\u0027",
                    "it": "Field \u0027Hello, World!\u0027",
                    "ja": "Field \u0027Hello, World!\u0027",
                    "la": "Field \u0027Hello, World!\u0027",
                    "ms": "Field \u0027Hello, World!\u0027",
                    "pl": "Field \u0027Hello, World!\u0027",
                    "ru": "Hello, World! Column",
                    "sc": "Field \u0027Hello, World!\u0027",
                    "tc": "Field \u0027Hello, World!\u0027",
                    "th": "Field \u0027Hello, World!\u0027",
                    "tr": "Field \u0027Hello, World!\u0027",
                    "vn": "Field \u0027Hello, World!\u0027"
                },
                "LIST_FILTER_LABEL": {
                    "ar": "Hello, World! Filter",
                    "br": "Hello, World! Filter",
                    "en": "Hello, World! Filter",
                    "fr": "Hello, World! Filter",
                    "id": "Hello, World! Filter",
                    "it": "Hello, World! Filter",
                    "ja": "Hello, World! Filter",
                    "la": "Hello, World! Filter",
                    "ms": "Hello, World! Filter",
                    "pl": "Hello, World! Filter",
                    "ru": "Hello, World! Filter",
                    "sc": "Hello, World! Filter",
                    "tc": "Hello, World! Filter",
                    "th": "Hello, World! Filter",
                    "tr": "Hello, World! Filter",
                    "vn": "Hello, World! Filter"
                },
                "ERROR_MESSAGE": {
                    "ar": "Field \u0027Hello, World!\u0027",
                    "br": "Field \u0027Hello, World!\u0027",
                    "en": "Hello, World! Error",
                    "fr": "Field \u0027Hello, World!\u0027",
                    "id": "Field \u0027Hello, World!\u0027",
                    "it": "Field \u0027Hello, World!\u0027",
                    "ja": "Field \u0027Hello, World!\u0027",
                    "la": "Field \u0027Hello, World!\u0027",
                    "ms": "Field \u0027Hello, World!\u0027",
                    "pl": "Field \u0027Hello, World!\u0027",
                    "ru": "Hello, World! Error",
                    "sc": "Field \u0027Hello, World!\u0027",
                    "tc": "Field \u0027Hello, World!\u0027",
                    "th": "Field \u0027Hello, World!\u0027",
                    "tr": "Field \u0027Hello, World!\u0027",
                    "vn": "Field \u0027Hello, World!\u0027"
                },
                "HELP_MESSAGE": {
                    "ar": "Field \u0027Hello, World!\u0027",
                    "br": "Field \u0027Hello, World!\u0027",
                    "en": "Hello, World! Help",
                    "fr": "Field \u0027Hello, World!\u0027",
                    "id": "Field \u0027Hello, World!\u0027",
                    "it": "Field \u0027Hello, World!\u0027",
                    "ja": "Field \u0027Hello, World!\u0027",
                    "la": "Field \u0027Hello, World!\u0027",
                    "ms": "Field \u0027Hello, World!\u0027",
                    "pl": "Field \u0027Hello, World!\u0027",
                    "ru": "Hello, World! Help",
                    "sc": "Field \u0027Hello, World!\u0027",
                    "tc": "Field \u0027Hello, World!\u0027",
                    "th": "Field \u0027Hello, World!\u0027",
                    "tr": "Field \u0027Hello, World!\u0027",
                    "vn": "Field \u0027Hello, World!\u0027"
                }
            },
            "time": {
                "start": 1724318753.341079,
                "finish": 1724318753.621247,
                "duration": 0.2801680564880371,
                "processing": 0.023567914962768555,
                "date_start": "2024-08-22T11:25:53+02:00",
                "date_finish": "2024-08-22T11:25:53+02:00",
                "operating": 0
            }
        }
        

Returned Data

Name
type

Description

result
userfield

Root element of the response, contains information about the custom field

time
time

Information about the request execution time

userfield

Parameter
type

Description

ID
integer

Identifier of the custom field

ENTITY_ID
string

String identifier binding the custom field to the entity.

In the case of methods crm.contact.userfield.*, the value CRM_CONTACT is automatically assigned

FIELD_NAME
string

Field code. Unique

USER_TYPE_ID
string

Data type of the custom field. Possible values:

  • string — string
  • integer — integer
  • double — number
  • boolean — yes/no
  • datetime — date/time
  • date — date
  • money — money
  • url — link
  • address — address
  • enumeration — list
  • file — file
  • employee — employee binding
  • crm_status — binding to CRM directory
  • iblock_section — binding to information block sections
  • iblock_element — binding to information block elements
  • crm — binding to CRM elements
  • custom field types

XML_ID
string

External code

SORT
integer

Sort index

MULTIPLE
boolean

Indicates whether the field is multiple. Possible values:

  • Y — yes
  • N — no

MANDATORY
boolean

Indicates whether the field is mandatory. Possible values:

  • Y — yes
  • N — no

SHOW_FILTER
boolean

Indicates whether to show the field in the filter. Possible values:

  • N — do not show
  • I — exact match
  • E — mask
  • S — substring

SHOW_IN_LIST
boolean

Indicates whether to show the custom field in the list.

This parameter does not affect anything within crm.

Possible values:

  • Y — yes
  • N — no

EDIT_IN_LIST
boolean

Allows user editing. Possible values:

  • Y — yes
  • N — no

IS_SEARCHABLE
boolean

Indicates whether the field values participate in search.

This parameter does not affect anything within crm.

Possible values:

  • Y — yes
  • N — no

SETTINGS
object

Additional field parameters. Each field type (USER_TYPE_ID) has its own set of available settings, which are described below

LIST
uf_enum_element[]

List of possible values for the custom field of type enumeration. For custom fields of other types, this parameter is meaningless

EDIT_FORM_LABEL
lang_map

Label in the edit form

LIST_COLUMN_LABEL
lang_map

Header in the list

LIST_FILTER_LABEL
lang_map

Filter label in the list

ERROR_MESSAGE
lang_map

Error message

HELP_MESSAGE
lang_map

Help

USER_TYPE_OWNER
string

CLIENT_ID of the application that serves this field type.

Returned when the field type is custom

Parameter settings

Name
type

Description

PRECISION
integer

Precision (number of decimal places)

SIZE
integer

Input field size for display

MIN_VALUE
double

Minimum value (0 — do not check)

MAX_VALUE
double

Maximum value (0 — do not check)

DEFAULT_VALUE
double

Default value

Name
type

Description

DEFAULT_VALUE
integer

Indicates whether it is the default value. Possible values:

  • 0 — no
  • 1 — yes

DISPLAY
string

Appearance. Possible values:

  • CHECKBOX — checkbox
  • RADIO — radio buttons
  • DROPDOWN — dropdown list

LABEL
string[]

Labels for values, where:

  • array element with index 0 — label for value No
  • array element with index 1 — label for value Yes

LABEL_CHECKBOX
string

Checkbox label

Name
type

Description

DEFAULT_VALUE
object

Default value. Object format:

{
            TYPE: 'NONE'|'FIXED'|'NONE',
            VALUE: date
        }
        

where:

  • TYPE — type of default value:
    • NONE — absent
    • NOW — current date
    • FIXED — date from the VALUE
  • VALUE is of type date

Name
type

Description

SIZE
integer

Input field size for display

MIN_VALUE
integer

Minimum value (0 — do not check)

MAX_VALUE
integer

Maximum value (0 — do not check)

DEFAULT_VALUE
integer

Default value

Name
type

Description

DEFAULT_VALUE
object

Default value. Object format:

{
            TYPE: 'NONE'|'FIXED'|'NONE',
            VALUE: datetime
        }
        

where:

  • TYPE — type of default value:
    • NONE — absent
    • NOW — current date with time
    • FIXED — date with time from the VALUE
  • VALUE is of type datetime

USE_SECOND
boolean

Whether to use seconds. Possible values:

  • Y — yes
  • N — no

USE_TIMEZONE
boolean

Whether to use time zones. Possible values:

  • Y — yes
  • N — no

Name
type

Description

SIZE
integer

Input field size for display

ROWS
integer

Number of lines in the input field

REGEXP
string

Regular expression for validation

MIN_LENGTH
integer

Minimum string length (0 — do not check)

MAX_LENGTH
integer

Maximum string length (0 — do not check)

DEFAULT_VALUE
string

Default value

Name
type

Description

DISPLAY
string

Appearance. Possible values:

  • LIST — list
  • CHECKBOX — checkboxes
  • UI — input list
  • DIALOG — entity selection dialog

LIST_HEIGHT
integer

List height

CAPTION_NO_VALUE
string

Label when no value is present

SHOW_NO_VALUE
boolean

Whether to show empty value for mandatory field. Possible values:

  • Y — yes
  • N — no

Name
type

Description

DISPLAY
string

Appearance. Possible values:

  • LIST — list
  • CHECKBOX — checkboxes
  • UI — input list
  • DIALOG — entity selection dialog

LIST_HEIGHT
integer

List height

IBLOCK_ID
integer

Identifier of the information block

DEFAULT_VALUE
integer

Default value

ACTIVE_FILTER
boolean

Show only active elements. Possible values:

  • Y — yes
  • N — no

Name
type

Description

ENTITY_TYPE
object

CRM directory. Structure is similar to the returned elements of the method crm.status.entity.types

Name
type

Description

LEAD
boolean

Whether binding to Leads is enabled

CONTACT
boolean

Whether binding to Contacts is enabled

COMPANY
boolean

Whether binding to Companies is enabled

DEAL
boolean

Whether binding to Deals is enabled

ORDER
boolean

Whether binding to Orders is enabled

QUOTE
boolean

Whether binding to Estimates is enabled

SMART_INVOICE
boolean

Whether binding to New Invoices is enabled

DYNAMIC_...
boolean

Whether binding to a specific SPA is enabled.

Each such field has the form: DYNAMIC_{entityTypeId}, where entityTypeId is the identifier of the type of SPA to which the binding is enabled

Name
type

Description

DEFAULT_VALUE
string

Default value.

The value of this field has the format: {VALUE}\|{CURRENCY}, where:

  • VALUE — default amount of money
  • CURRENCY — string identifier of the currency

For example: 300\|USD — 300 dollars

Name
type

Description

SHOW_MAP
boolean

Show map

Name
type

Description

POPUP
boolean

Open in a new window

SIZE
integer

Input field size for display

MIN_LENGTH
integer

Minimum string length (0 — do not check)

MAX_LENGTH
integer

Maximum string length (0 — do not check)

DEFAULT_VALUE
string

Default value

ROWS
integer

Number of lines in the input field

Name
type

Description

SIZE
integer

Input field size for display

LIST_WIDTH
integer

Maximum width for display in the list

LIST_HEIGHT
integer

Maximum height for display in the list

MAX_SHOW_SIZE
integer

Maximum allowed size for display in the list (0 — no limit)

MAX_ALLOWED_SIZE
integer

Maximum allowed file size for upload (0 — do not check)

EXTENSIONS
string[]

Allowed extensions

TARGET_BLANK
boolean

Open file in a new tab

Type uf_enum_element

Name
type

Description

ID
integer

Identifier of the list element

VALUE
string

Value of the list element

SORT
integer

Sort index

DEF
boolean

Indicates whether the list element is the default value. Possible values:

  • Y — yes
  • N — no

Error Handling

HTTP Status: 400

{
            "error": "",
            "error_description": "ID is not defined or invalid."
        }
        

Name
type

Description

error
string

String error code. It may consist of digits, Latin letters, and underscores

error_description
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

Occurs when:

  • the user does not have administrative rights
  • the user attempts to access a custom field not linked to contacts

-

ID is not defined or invalid

The provided id is less than or equal to zero, or is not provided at all

ERROR_NOT_FOUND

The entity with ID 'id' is not found

The custom field with the provided id was not found

Statuses and System Error Codes

HTTP Status: 20x, 40x, 50x

The errors described below may occur when calling any method.

Status

Code
Error Message

Description

500

INTERNAL_SERVER_ERROR
Internal server error

An internal server error has occurred, please contact the server administrator or Bitrix24 technical support

500

ERROR_UNEXPECTED_ANSWER
Server returned an unexpected response

An internal server error has occurred, please contact the server administrator or Bitrix24 technical support

503

QUERY_LIMIT_EXCEEDED
Too many requests

The request intensity limit has been exceeded

405

ERROR_BATCH_METHOD_NOT_ALLOWED
Method is not allowed for batch usage

The current method is not allowed to be called using batch

400

ERROR_BATCH_LENGTH_EXCEEDED
Max batch length exceeded

The maximum length of parameters passed to the batch method has been exceeded

401

NO_AUTH_FOUND
Wrong authorization data

Invalid access token or webhook code

400

INVALID_REQUEST
Https required

The methods must be called using the HTTPS protocol

503

OVERLOAD_LIMIT
REST API is blocked due to overload

The REST API is blocked due to overload. This is a manual individual block, to remove it you need to contact Bitrix24 technical support

403

ACCESS_DENIED
REST API is available only on commercial plans

The REST API is available only on commercial plans

403

INVALID_CREDENTIALS
Invalid request credentials

The user whose access token or webhook was used to call the method lacks permissions

404

ERROR_MANIFEST_IS_NOT_AVAILABLE
Manifest is not available

The manifest is not available

403

insufficient_scope
The request requires higher privileges than provided by the webhook token

The request requires higher privileges than those provided by the webhook token

401

expired_token
The access token provided has expired

The provided access token has expired

403

user_access_error
The user does not have access to the application

The user does not have access to the application. This means that the application is installed, but the account administrator has allowed access to this application only for specific users

500

PORTAL_DELETED
Portal was deleted

The public part of the site is closed. To open the public part of the site on an on-premise installation, disable the option "Temporary closure of the public part of the site". Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site

Continue Learning