Update Values of Custom Fields for Inventory Documents catalog.userfield.document.update

We are still updating this page

Some data may be missing — we will complete it shortly.

Scope: catalog

Who can execute the method: any user

catalog.userfield.document.update(documentId, fields)
        

This method updates the values of custom fields for inventory documents.

Parameters

Parameter

Description

documentId
integer

Identifier of the inventory document.

fields
object

Fields to be updated and their new values. documentType must be specified – type of inventory documents.

Required parameters are marked with *

Example

In the API, field names are represented as field[Field ID in the database] – for example, field287. The field ID can be obtained using the method userfieldconfig.list.

try
        {
        	const response = await $b24.callMethod(
        		'catalog.userfield.document.update',
        		{
        			documentId: 64,
        			fields: {
        				'documentType': 'S',
        				'field287': 'new value'
        			}
        		}
        	);
        	
        	const result = response.getData().result;
        	console.log(result);
        }
        catch( error )
        {
        	console.error(error.ex);
        }
        
try {
            $response = $b24Service
                ->core
                ->call(
                    'catalog.userfield.document.update',
                    [
                        'documentId' => 64,
                        'fields'     => [
                            'documentType' => 'S',
                            'field287'     => 'new value'
                        ]
                    ]
                );
        
            $result = $response
                ->getResponseData()
                ->getResult();
        
            if ($result->error()) {
                error_log($result->error()->ex);
            } else {
                echo 'Success: ' . print_r($result->data(), true);
            }
        
        } catch (Throwable $e) {
            error_log($e->getMessage());
            echo 'Error updating document user field: ' . $e->getMessage();
        }
        
BX24.callMethod(
            'catalog.userfield.document.update',
            {
                documentId: 64,
                fields: {
                    'documentType': 'S',
                    'field287': 'new value'
                }
            },
            function(result)
            {
                if(result.error())
                    console.error(result.error().ex);
                else
                    console.log(result.data());
            }
        );
        

How to Use Examples in Documentation