Skip to content

Latest commit

 

History

History
274 lines (214 loc) · 7.17 KB

File metadata and controls

274 lines (214 loc) · 7.17 KB

Get a List of Product Fields for the Warehouse Accounting Document catalog.document.element.fields

{% note tip "" %}

Choose a tool for developing with an AI agent:

  • use Alaio Vibecode to build an app for Bitrix24 from a task description without knowing any programming language. The agent writes the code and deploys the app to a server, with no manual hosting setup
  • use the MCP server to develop a REST API integration in your own project. The agent refers to the official REST documentation

{% endnote %}

Scope: catalog

Who can execute the method: administrator

{% note warning "DEPRECATED" %}

The development of this method has been halted. Please use catalog.document.element.getFields.

{% endnote %}

The method catalog.document.element.fields returns a list of product fields for the warehouse accounting document.

Method Parameters

No parameters.

Code Examples

{% include Examples Note %}

{% list tabs %}

  • cURL (Webhook)

    curl -X POST \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -d '{}' \
    https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/catalog.document.element.fields
  • cURL (OAuth)

    curl -X POST \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -d '{"auth":"**put_access_token_here**"}' \
    https://**put_your_bitrix24_address**/rest/catalog.document.element.fields
  • JS (TS)

    // This snippet is an ES module: top-level await requires type="module" or a bundler.
    // $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
    import { Text } from '@bitrix24/b24jssdk'
    import type { B24Frame } from '@bitrix24/b24jssdk'
    
    declare const $b24: B24Frame
    
    type FieldInfo = {
      isRequired: boolean
      isReadOnly: boolean
      isImmutable: boolean
      isMultiple: boolean
      isDynamic: boolean
      title: string
      type: string
    }
    
    // Shape of the payload returned in result (match the "response handling" section of the page)
    type DocumentElementFieldsResult = Record<string, FieldInfo>[]
    
    try {
      const response = await $b24.actions.v2.call.make<DocumentElementFieldsResult>({
        method: 'catalog.document.element.fields',
        params: {},
        requestId: Text.getUuidRfc4122()
      })
    
      // The payload is available only on a successful response
      if (!response.isSuccess) {
        console.error(response.getErrorMessages().join('; '))
      } else {
        const result = response.getData()!.result
        console.info(Object.keys(result))
      }
    } catch (error) {
      // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
      console.error(error)
    }
  • JS (UMD)

    <!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
    <script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
    <script>
      async function getDocumentElementFields() {
        try {
          // Initialize the SDK inside a Bitrix24 frame
          const $b24 = await B24Js.initializeB24Frame()
    
          const response = await $b24.actions.v2.call.make({
            method: 'catalog.document.element.fields',
            params: {},
            requestId: B24Js.Text.getUuidRfc4122()
          })
    
          // The payload is available only on a successful response
          if (!response.isSuccess) {
            console.error(response.getErrorMessages().join('; '))
            return
          }
    
          const result = response.getData().result
          console.info(Object.keys(result))
        } catch (error) {
          // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
          console.error(error)
        }
      }
    
      document.addEventListener('DOMContentLoaded', getDocumentElementFields)
    </script>
  • PHP

    try {
        $response = $b24Service
            ->core
            ->call(
                'catalog.document.element.fields',
                []
            );
    
        $result = $response
            ->getResponseData()
            ->getResult();
    
        if ($result->error()) {
            error_log($result->error());
        } else {
            echo 'Success: ' . print_r($result->data(), true);
        }
    
    } catch (Throwable $e) {
        error_log($e->getMessage());
        echo 'Error calling catalog document element fields: ' . $e->getMessage();
    }
  • BX24.js

    BX24.callMethod(
        'catalog.document.element.fields',
        {},
        function(result)
        {
            if(result.error())
                console.error(result.error());
            else
                console.log(result.data());
        }
    );
  • PHP CRest

    require_once('crest.php');
    
    $result = CRest::call(
        'catalog.document.element.fields',
        []
    );
    
    echo '<PRE>';
    print_r($result);
    echo '</PRE>';
  • Go

    // client and ctx are already created — see the Go SDK section
    res, err := client.Core().Call(ctx, "catalog.document.element.fields", nil, b24.WithIdempotent())
    if err != nil {
    	return fmt.Errorf("catalog.document.element.fields: %w", err)
    }
    
    // The response arrives as json.RawMessage — unmarshal it
    // into a struct matching the response shape shown below on this page.
    fmt.Printf("%s\n", res.Result)

{% endlist %}

Response Handling

HTTP status: 200

{
    "result": [
        {
            "id": {
                "type": "integer",
                "isRequired": false,
                "isReadOnly": true,
                "isImmutable": false,
                "isMultiple": false,
                "isDynamic": false,
                "title": "ID"
            }
        }
    ],
    "time": {
        "start": 1759482402.511337,
        "finish": 1759482402.642843,
        "duration": 0.13150620460510254,
        "processing": 0.02694106101989746,
        "date_start": "2025-11-02T12:26:42+03:00",
        "date_finish": "2025-11-02T12:26:42+03:00",
        "operating": 0
    }
}

Returned Data

#| || Name type | Description || || result object[] | Array with descriptions of inventory document product fields || || time time | Information about the request execution time || |#

Error Handling

HTTP status: 400

{
    "error": "ERROR_DOCUMENT_RIGHTS",
    "error_description": "Access denied"
}

{% include notitle error handling %}

Possible Error Codes

#| || Code | Description | Value || || ERROR_DOCUMENT_RIGHTS | Access denied | Insufficient permissions to read inventory documents || |#

{% include System Errors %}

Continue Learning