lists.element.update
Scope: catalog Permissions to execute: for all
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:
- 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.
- Get the ID list of uploaded files.
- 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
Parameter | Description |
---|---|
All fields for element and their values must be passed in the query. | |
IBLOCK_TYPE_ID | Information block ID (required):
|
IBLOCK_CODE/IBLOCK_ID | code or ID for information block (required) |
ELEMENT_CODE/ELEMENT_ID | code or ID for element (required) |
FIELDS | array of fields and values |
SOCNET_GROUP_ID | group 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()); } );
© «Bitrix24», 2001-2024