Custom Lead Fields: Overview of Methods

Custom fields store information about a lead in various data formats: string, number, link, address, and others.

Quick navigation: all methods

User documentation: Custom fields in CRM

Types of Custom Fields

Use the method crm.userfield.types to retrieve the available types of custom fields. The method will return the ID and name of the field types.

    (
                [ID] => double    
                [title] => Number
            )
        

Use the method crm.userfield.fields to get a list of characteristics of custom fields. The method will return the codes of the characteristics along with their type and name.

    [MANDATORY] => Array
                        (
                            [type] => char
                            [title] => Required
                        )
        

Custom Field Settings

Use the method crm.userfield.settings.fields to obtain a list of available settings. The method will return the supported settings for the requested field type.

    [DEFAULT_VALUE] => Array
                    (
                        [type] => double
                        [title] => Default value
                    )
            [PRECISION] => Array
                    (
                        [type] => int
                        [title] => Precision
                    )
        

Errors When Working with Custom Fields

When creating or deleting custom fields, the request may be interrupted with an error INTERNAL_SERVER_ERROR. This is an internal server error. The cause of the error can be found in the server logs at the time of the request:

  • In cloud Bitrix24, submit a request to technical support to get details about the error.
  • In on-premise Bitrix24, request the server error log from the server administrator or hosting administrator. Then, contact technical support and attach the log for analysis.

Common Causes of Server Errors

  1. Up to 1016 custom fields can be created for leads—this is a limitation of the database architecture. If there are already 1016 fields for leads in Bitrix24, attempting to create a new field will result in the method crm.lead.userfield.add returning an error INTERNAL_SERVER_ERROR.

    You can check the number of custom fields for leads using the method crm.lead.userfield.list.

  2. There is a limitation on servers for the execution time of a single request—max_execution_time. The standard time is 60 seconds. If the request takes longer, it will be interrupted with an error INTERNAL_SERVER_ERROR.

    The time for creating or deleting a custom field for leads depends on the number of leads. When a field is created, it is added to all lead detail forms. When a field is deleted, it is removed from all detail forms. The fewer leads in your Bitrix24, the faster fields are created and deleted.

    To check the number of leads in Bitrix24, use the method crm.lead.list.

Overview of Methods

Scope: crm

Who can perform the methods: depending on the method

Method

Description

crm.lead.userfield.add

Creates a new custom field for leads

crm.lead.userfield.update

Updates an existing custom field for leads

crm.lead.userfield.get

Returns a custom field for leads by ID

crm.lead.userfield.list

Returns a list of custom fields for leads by filter

crm.lead.userfield.delete

Deletes a custom field for leads

Event

Triggered

onCrmLeadUserFieldAdd

When a custom field is added

onCrmLeadUserFieldUpdate

When a custom field is updated

onCrmLeadUserFieldDelete

When a custom field is deleted

onCrmLeadUserFieldSetEnumValues

When the set of values for a list-type custom field is changed