Documentation

lists.field.add

Scope: lists Permissions to execute: for all

Description

lists.field.add (params)

This method create a list field. Returns true on success, otherwise throws an exception.

Parameters

ParameterDescription
IBLOCK_TYPE_ID information block type ID (required):
  • lists - information block type for lists
  • bitrix_processes - information block type for processes
  • lists_socnet - information block type for workgroup lists
IBLOCK_CODE/IBLOCK_IDcode or ID for information block (required);
SOCNET_GROUP_IDgroup ID (required, for a group list);
FIELDS (key are the same hen creating field from Bitrix24 interface)
  • NAME name (required)
  • IS_REQUIRED required mark
  • MULTIPLE multiple mark
  • TYPE type (required)
    • S - String
    • N - Number
    • L - List
    • F - FIle
    • G - Binding to sections
    • E - Binding to elements
    • S:Date - Date
    • S:DateTime - Date/Time
    • S:HTML - HTML/text
    • E:EList - Binding to elements as a list. When creating a field with this type, you must indicate LINK_IBLOCK_ID id for information block, which elements will be displayed in selector for this field.
    • N:Sequence - Counter
    • S:Money - Money
    • S:DiskFile - FIle (Drive)
    • S:employee - Binding to employee
    • S:ECrm - Binding to CRM elements
  • SORT sorting
  • DEFAULT_VALUE value by default
  • LIST - can be used to add values to 'List' type fields.
    • n0 - item string
      • SORT - sorting value
      • VALUE - item value
  • LIST_TEXT_VALUES - can be used to add ''List'' type field values via the string (Each unique string will become a separate value of the list).
  • LIST_DEF - value by default for "List" type field (Format: array with the value, where the ID value of the list item)
  • CODE code (required, if a field is the information block property)
  • SETTINGS all keys shall be available, otherwise overwrite to default values will occur
    • SHOW_ADD_FORM - show in the add form
    • SHOW_EDIT_FORM - show in the edit form
    • ADD_READ_ONLY_FIELD - read only (add form)
    • EDIT_READ_ONLY_FIELD - read only (edit form)
    • SHOW_FIELD_PREVIEW - show field during forming of the link to the list element
  • USER_TYPE_SETTINGS - key to pass user settings
  • ROW_COUNT/COL_COUNT - setting for textarea fields
  • LINK_IBLOCK_ID - ID of linked section

Example

   var params = {
        'IBLOCK_TYPE_ID': 'lists_socnet',
        'IBLOCK_CODE': 'rest_1',
        'FIELDS': {
            'NAME': 'List field',
            'IS_REQUIRED': 'Y',
            'MULTIPLE': 'N',
            'TYPE': 'L',
            'SORT': '20',
            'CODE': 'fieldList',
            'LIST_TEXT_VALUES': 'one\ntwo\nthree',
            'SETTINGS': {
                'SHOW_ADD_FORM': 'Y',
                'SHOW_EDIT_FORM': 'Y',
                'ADD_READ_ONLY_FIELD': 'N',
                'EDIT_READ_ONLY_FIELD': 'N',
                'SHOW_FIELD_PREVIEW': 'N'
            }
        }
    };
    BX24.callMethod(
        'lists.field.add',
        params,
        function(result)
        {
            if(result.error())
                alert("Error: " + result.error());
            else
                alert("Success: " + result.data());
        }
    );


© «Bitrix24», 2001-2024