Views: 225
Last Modified: 17.08.2020

Creating field and field type

Register a field type.

Create a custom field or via API. For example, use crm.lead.userfield.add for CRM Leads.

Processing data within IFRAME

When a CRM lead details form opens and displays your custom field, it essentially displays a frame with application. All data about field, value, and operation mode is passed into this frame. For the app it all looks like it was opened in the embedding location with identifier USERFIELD_TYPE.

Here's example of POST data that frame receives:

Array
(
    [DOMAIN] => sometestportal.bitrix24.com
    [PROTOCOL] => 1
    [LANG] => com
    [APP_SID] => 14d2c95b446cb049375e4a045dc2a177
    [AUTH_ID] => xomlj71xez3p4q8bqsb5icqjcgjetf0p
    [AUTH_EXPIRES] => 3600
    [REFRESH_ID] => 51556ja184k22cqot442w0lp1quxg0p2
    [member_id] => 6f61b5484aff6f8aa3fef768153d0226
    [status] => L
    [PLACEMENT] => USERFIELD_TYPE
    [PLACEMENT_OPTIONS] => {"MODE":"view","ENTITY_ID":"CRM_LEAD","FIELD_NAME":"UF_CRM_1511508634350","ENTITY_VALUE_ID":"2","VALUE":["\u0435\u0445\u0430\u043b \u0433\u0440\u0435\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u043a\u0443","\u0432\u0438\u0434\u0438\u0442 \u0433\u0440\u0435\u043a\u0430 \u0432 \u0440\u0435\u043a\u0435 \u0440\u0430\u043a","c\u0443\u043d\u0443\u043b \u0433\u0440\u0435\u043a\u0430 \u0440\u0443\u043a\u0443 \u0432 \u0440\u0435\u043a\u0443","\u0440\u0430\u043a \u0437\u0430 \u0440\u0443\u043a\u0443 \u0433\u0440\u0435\u043a\u0430 \u0446\u0430\u043f"],"MULTIPLE":"Y","MANDATORY":"N","XML_ID":null}
)

Let's examine JSON string PLACEMENT_OPTIONS in detail:

Array
(
    [MODE] => view
    [ENTITY_ID] => CRM_LEAD
    [FIELD_NAME] => UF_CRM_1511508634350
    [ENTITY_VALUE_ID] => 2
    [VALUE] => Array
        (
            [0] => here goes the mailman
            [1] => he is bringing event post
            [2] => herald yellowish newspaper
            [3] => highlighting our green wallpaper
        )

    [MULTIPLE] => Y
    [MANDATORY] => N
    [XML_ID] => 
)

Keys:

Key Description
MODE Mode when calling a field. Values: view - for viewing, edit - for editing
ENTITY_ID Entity ID with field binded
FIELD_NAME Custom field ID
ENTITY_VALUE_ID Entity ID with edited field value
VALUE Current field value. Array of values for multiple field.
MULTIPLE multiple field flag
MANDATORY mandatory field flag
XML_ID field external ID

JS interface

JS interface for custom user field is also available for getting and setting the value:

BX24.placement.call('getValue', function(value){console.log(value)});

[here goes the mailman", "he is bringing event post", "herald yellowish newspaper", "highlighting our green wallpaper"]

BX24.placement.call('setValue', ["here goes the mailman", "he is bringing event post", "herald yellowish newspaper", "highlighting our green wallpaper"], function(){console.log('value set')});

value set

It must be considered that JS interface serves explicitly for passing data to the form. Until the form isn't saved by the user, no value is written into the database.

Demo application

Demo application that registers standard text field with its own input/output interface. Download




Courses developed by «Bitrix», Inc.