Get Company Custom Field by ID crm.company.userfield.get

Choose a tool for developing with an AI agent:

  • use Alaio Vibecode to build an app for Bitrix24 from a task description without knowing any programming language. The agent writes the code and deploys the app to a server, with no manual hosting setup
  • use the MCP server to develop a REST API integration in your own project. The agent refers to the official REST documentation

Scope: crm

Who can execute the method: a user with read access permission for companies

The method crm.company.userfield.get returns a company custom field by its ID.

Method Parameters

Required parameters are marked with *

Name
type

Description

id*
integer

Identifier of the custom field associated with the company.

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

Code Examples

How to Use Examples in Documentation

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.company.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.company.userfield.get
        
// This snippet is an ES module: top-level await requires type="module" or a bundler.
        // $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
        import { Text } from '@bitrix24/b24jssdk'
        import type { B24Frame } from '@bitrix24/b24jssdk'
        
        declare const $b24: B24Frame
        
        // Shape of the payload returned in result (match the "response handling" section of the page)
        type CrmCompanyUserfield = {
          ID: string
          ENTITY_ID: string
          FIELD_NAME: string
          USER_TYPE_ID: string
          XML_ID: string | null
          SORT: string
          MULTIPLE: string
          MANDATORY: string
        }
        
        try {
          const response = await $b24.actions.v2.call.make<CrmCompanyUserfield>({
            method: 'crm.company.userfield.get',
            params: {
              id: 399,
            },
            requestId: Text.getUuidRfc4122()
          })
        
          // The payload is available only on a successful response
          if (!response.isSuccess) {
            console.error(response.getErrorMessages().join('; '))
          } else {
            const result = response.getData()!.result
            console.info('Userfield:', result.ID, result.FIELD_NAME)
          }
        } catch (error) {
          // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
          console.error(error)
        }
        
<!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
        <script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
        <script>
          async function getCompanyUserfield() {
            try {
              // Initialize the SDK inside a Bitrix24 frame
              const $b24 = await B24Js.initializeB24Frame()
        
              const response = await $b24.actions.v2.call.make({
                method: 'crm.company.userfield.get',
                params: {
                  id: 399,
                },
                requestId: B24Js.Text.getUuidRfc4122()
              })
        
              // The payload is available only on a successful response
              if (!response.isSuccess) {
                console.error(response.getErrorMessages().join('; '))
                return
              }
        
              const result = response.getData().result
              console.info('Userfield:', result.ID, result.FIELD_NAME)
            } catch (error) {
              // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
              console.error(error)
            }
          }
        
          document.addEventListener('DOMContentLoaded', getCompanyUserfield)
        </script>
        

        from b24pysdk.errors import BitrixAPIError, BitrixSDKException
        
        try:
            bitrix_response = client.crm.company.userfield.get(
                bitrix_id=399,
            ).response
            result = bitrix_response.result
            print(result)
        except BitrixAPIError as error:
            print(
                "Bitrix API Error",
                f"error: {error.error}",
                f"error_description: {error.error_description}",
                sep="\n",
            )
        except BitrixSDKException as error:
            print(f"Bitrix SDK Error: {error.message}")
        except Exception as error:
            print(f"Unexpected error: {error}")
        
try {
            $response = $b24Service
                ->core
                ->call(
                    'crm.company.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 company user field: ' . $e->getMessage();
        }
        
BX24.callMethod(
            'crm.company.userfield.get',
            {
                id: 399,
            },
            (result) => {
                result.error()
                    ? console.error(result.error())
                    : console.info(result.data())
                ;
            },
        );
        
require_once('crest.php');
        
        $result = CRest::call(
            'crm.company.userfield.get',
            [
                'id' => 399
            ]
        );
        
        echo '<PRE>';
        print_r($result);
        echo '</PRE>';
        
// client and ctx are already created — see the Go SDK section
        res, err := client.Core().Call(ctx, "crm.company.userfield.get", b24.Params{
        	"id": 399,
        }, b24.WithIdempotent())
        if err != nil {
        	return fmt.Errorf("crm.company.userfield.get: %w", err)
        }
        
        var item struct {
        	ID         b24.ID `json:"ID"`
        	EntityID   string `json:"ENTITY_ID"`
        	FieldName  string `json:"FIELD_NAME"`
        	UserTypeID string `json:"USER_TYPE_ID"`
        	Sort       string `json:"SORT"`
        	Multiple   string `json:"MULTIPLE"`
        }
        if err := json.Unmarshal(res.Result, &item); err != nil {
        	return fmt.Errorf("parse response: %w", err)
        }
        fmt.Println(item.ID, item.EntityID)
        

Response Handling

HTTP status: 200

{
            "result": {
                "ID": "6997",
                "ENTITY_ID": "CRM_COMPANY",
                "FIELD_NAME": "UF_CRM_HELLO_WORLD",
                "USER_TYPE_ID": "string",
                "XML_ID": null,
                "SORT": "2000",
                "MULTIPLE": "Y",
                "MANDATORY": "N",
                "SHOW_FILTER": "N",
                "SHOW_IN_LIST": "Y",
                "EDIT_IN_LIST": "N",
                "IS_SEARCHABLE": "N",
                "SETTINGS": {
                    "SIZE": 20,
                    "ROWS": 10,
                    "REGEXP": "",
                    "MIN_LENGTH": 0,
                    "MAX_LENGTH": 0,
                    "DEFAULT_VALUE": "Hello, world! Default value (changed)"
                },
                "EDIT_FORM_LABEL": {
                    "ar": "",
                    "br": "",
                    "de": "Hallo, Welt! Bearbeiten (geändert)",
                    "en": "Hello, World! Edit (changed)",
                    "fr": "",
                    "hi": "",
                    "id": "",
                    "in": "",
                    "it": "",
                    "ja": "",
                    "kz": "",
                    "la": "",
                    "ms": "",
                    "pl": "",
                    "sc": "",
                    "tc": "",
                    "th": "",
                    "tr": "",
                    "ua": "",
                    "vn": ""
                },
                "LIST_COLUMN_LABEL": {
                    "ar": "",
                    "br": "",
                    "de": "Hallo, Welt! Spalte (geändert)",
                    "en": "Hello, World! Column (changed)",
                    "fr": "",
                    "hi": "",
                    "id": "",
                    "in": "",
                    "it": "",
                    "ja": "",
                    "kz": "",
                    "la": "",
                    "ms": "",
                    "pl": "",
                    "sc": "",
                    "tc": "",
                    "th": "",
                    "tr": "",
                    "ua": "",
                    "vn": ""
                },
                "LIST_FILTER_LABEL": {
                    "ar": "Hello, world! Filter (changed)",
                    "br": "Hello, world! Filter (changed)",
                    "de": "Hello, world! Filter (changed)",
                    "en": "Hello, world! Filter (changed)",
                    "fr": "Hello, world! Filter (changed)",
                    "hi": "Hello, world! Filter (changed)",
                    "id": "Hello, world! Filter (changed)",
                    "in": "Hello, world! Filter (changed)",
                    "it": "Hello, world! Filter (changed)",
                    "ja": "Hello, world! Filter (changed)",
                    "kz": "Hello, world! Filter (changed)",
                    "la": "Hello, world! Filter (changed)",
                    "ms": "Hello, world! Filter (changed)",
                    "pl": "Hello, world! Filter (changed)",
                    "sc": "Hello, world! Filter (changed)",
                    "tc": "Hello, world! Filter (changed)",
                    "th": "Hello, world! Filter (changed)",
                    "tr": "Hello, world! Filter (changed)",
                    "ua": "Hello, world! Filter (changed)",
                    "vn": "Hello, world! Filter (changed)"
                },
                "ERROR_MESSAGE": {
                    "ar": "",
                    "br": "",
                    "de": "Hallo, Welt! Fehler (geändert)",
                    "en": "Hello, World! Error (changed)",
                    "fr": "",
                    "hi": "",
                    "id": "",
                    "in": "",
                    "it": "",
                    "ja": "",
                    "kz": "",
                    "la": "",
                    "ms": "",
                    "pl": "",
                    "sc": "",
                    "tc": "",
                    "th": "",
                    "tr": "",
                    "ua": "",
                    "vn": ""
                },
                "HELP_MESSAGE": {
                    "ar": "",
                    "br": "",
                    "de": "Hallo, Welt! Hilfe (geändert)",
                    "en": "Hello, World! Help (changed)",
                    "fr": "",
                    "hi": "",
                    "id": "",
                    "in": "",
                    "it": "",
                    "ja": "",
                    "kz": "",
                    "la": "",
                    "ms": "",
                    "pl": "",
                    "sc": "",
                    "tc": "",
                    "th": "",
                    "tr": "",
                    "ua": "",
                    "vn": ""
                }
            },
            "time": {
                "start": 1753790529.430936,
                "finish": 1753790529.487882,
                "duration": 0.05694580078125,
                "processing": 0.0039789676666259766,
                "date_start": "2025-07-29T15:02:09+03:00",
                "date_finish": "2025-07-29T15:02:09+03:00",
                "operating_reset_at": 1753791129,
                "operating": 0
            }
        }
        

Returned Data

Name
type

Description

result
object

Response object. Its fields are described below

time
time

Information about the request execution time

Fields of the Result Object

Field
type

Description

ID
string

Numeric custom field ID as a string

ENTITY_ID
string

CRM object code. For a company custom field, CRM_COMPANY

FIELD_NAME
string

Full field code with the UF_CRM_ prefix

USER_TYPE_ID
string

Custom field type. Available types are returned by crm.userfield.types

XML_ID
string|null

External field code. Returns null if not set

SORT
string

Sort index as a string

MULTIPLE
string

Multiple field: Y for yes, N for no

MANDATORY
string

Required field: Y for yes, N for no

SHOW_FILTER
string

Filter display mode: N for hidden, I for exact match, E for pattern, S for substring

SHOW_IN_LIST
string

Show the field in the list: Y for yes, N for no

EDIT_IN_LIST
string

Allow editing in the list: Y for yes, N for no

IS_SEARCHABLE
string

Include field values in search: Y for yes, N for no

SETTINGS
object

Field settings. Keys depend on USER_TYPE_ID; retrieve their descriptions with crm.userfield.settings.fields

EDIT_FORM_LABEL
object

Field labels in the edit form, keyed by language code

LIST_COLUMN_LABEL
object

List column headings, keyed by language code

LIST_FILTER_LABEL
object

Field labels in the filter, keyed by language code

ERROR_MESSAGE
object

Error messages, keyed by language code

HELP_MESSAGE
object

Help text, keyed by language code

LIST
object[]

List items if USER_TYPE_ID is enumeration. Each item contains ID, SORT, VALUE, and DEF

USER_TYPE_OWNER
string

Application ID if the field uses a custom type registered by an application

Error Handling

HTTP status: 400

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

Name
type

Description

error
string

String error code. It consists of digits, Latin letters, and underscores. It may arrive empty — in that case only error_description shows the reason

error_description
string

Error message for the developer. Do not show it to the end user without processing

Possible Error Codes

Code

Description

Value

Empty value

Access denied

Occurs when:

  • the user does not have read access permission for companies
  • the user attempts to access a custom field not associated with companies

Empty value

ID is not defined or invalid

The provided id is less than or equal to zero or was not provided

ERROR_NOT_FOUND

The entity with ID 'id' is not found

The custom field with the provided id was not found

Continue Learning