Documentation

lists.element.update

Description

lists.element.update(params, fields)

This method updates a list element. Returns true on success, otherwise throws an exception.


Important! Query must pass All fields with values for an element.


To upload files in the File (Disk) field type, proceed as follows:

  1. Use REST API of the disk module: disk.folder.uploadfile and disk.storage.uploadfile. The response will contain the "ID": 290 when the files are uploaded.
  2. Get the ID list of uploaded files.
  3. Then add files to the required field via the List module REST API. In case if the field already has the attached files, you must get previous values via the lists.element.get and pass them with the new values:
    var params = {
     'IBLOCK_TYPE_ID': 'lists',
     'IBLOCK_ID': '41',
     'ELEMENT_CODE': 'element1',
     'FIELDS': {
         'NAME': 'Test element 1',
         'PROPERTY_121': {'4754': ['50', 'n1582']} // or without id 'PROPERTY_121': {'n0': ['50', 'n1582']}
     }
    };
    BX.rest.callMethod(
     'lists.element.update',
     params,
     function(result)
     {
         if(result.error())
             alert("Error: " + result.error());
         else
             alert("Success: " + result.data());
     }
    );

    Values in the File (Disk) field without the "n" prefix designate the already attached files (attachedId). If the files have the prefix - these are your new files, which were preliminarily uploaded to the disk.

Parameters

ParameterDescription
All fields for element and their values must be passed in the query.
IBLOCK_TYPE_IDInformation block ID (required):
  • lists - information block type for lists
  • bitrix_processes - information block type for processes
  • lists_socnet - information block type for group lists
IBLOCK_CODE/IBLOCK_IDcode or ID for information block (required)
ELEMENT_CODE/ELEMENT_IDcode or ID for element (required)
FIELDSarray of fields and values
SOCNET_GROUP_IDgroup ID (required, if list is created for group);

Examples

var params = {
        'IBLOCK_TYPE_ID': 'lists_socnet',
        'IBLOCK_CODE': 'rest_1',
        'ELEMENT_CODE': 'element_1',
        'FIELDS': {
            'NAME': 'Test element (Update)',
            'PROPERTY_62': {
                '599': 'Text string (Update)'
            },
            'PROPERTY_63': {
                '600': '73',
                '601': '97',
                '602': '17'
            }
        }
    };
    BX24.callMethod(
        'lists.element.update',
        params,
        function(result)
        {
            if(result.error())
                alert("Error: " + result.error());
            else
                alert("Success: " + result.data());
        }
    );

var params = {
        'IBLOCK_TYPE_ID': 'bitrix_processes',
      'IBLOCK_ID': '154',
      'ELEMENT_ID': '15318',
      'FIELDS': {
          'NAME': 'Test element (Update)',
          'PROPERTY_2946': {
              'n0': 'n3374'
          }
      }
  };
  BX24.callMethod(
      'lists.element.update',
      params,
      function(result)
      {
          if(result.error())
              alert("Error: " + result.error());
          else
              alert("Success: " + result.data());
      }
  );


© «Bitrix24», 2001-2023
Up