apibitrix

Bitrix24: Fill in listvalue via the Api with lists.element.add


I to choose a list-value via the API into Bitrix

CRest::call('lists.element.add',
        [ 'IBLOCK_TYPE_ID' => 'lists',
         'IBLOCK_ID' => '134',
         'ELEMENT_CODE' => 'element'.$entry[134] ,
         'FIELDS' => [
         'NAME' =>  'TEST'.$leadID, 
         'PROPERTY_1430' => 'YES or NO' ,
         ]
        ]             

Ho do i set the Value for Protpery_1430? Here "Yes or NO"

There is a screenshot of the values of the Ja (Yes) and (NO): There is a screenshot of the values of the Ja (Yes) and (NO

Some help would be nice :) Roland


Solution

  • Just pass the list variant identifier; e.g.:

    CRest::call('lists.element.add', [
        'IBLOCK_TYPE_ID' => 'lists',
        'IBLOCK_ID' => '134',
        'ELEMENT_CODE' => 'element'.$entry[134] ,
        'FIELDS' => [
            'NAME' =>  'TEST'.$leadID, 
            'PROPERTY_1430' => 2463, // or 2464
        ]
    ];
    

    If you can't use identifiers and need to use values, use the lists.field.get method and find the identifier by the value from the DISPLAY_VALUES_FORM field.