Back to blog
SAPP BlogBitrix24 integrations

CRM product rows through REST: adding a row and replacing the entire set

How to choose an operation for deal products without losing existing rows when synchronizing an order.

Step 1

Define what the operation means

An external order may be the full source of the product set or may provide only an additional row. In the first case, a controlled replacement of the set is appropriate; in the second, use a method that adds an individual row.

If a manager edits products in the CRM, synchronizing a complete old copy of the order may delete those changes. Define the owner of the product set and the procedure for resolving differences.

It is useful to document the data exchange scope and data owners in a working document: Acceptance evidence package for Bitrix24: scenarios, snapshots and the launch decision. If you need to examine a specific portal scenario, see the service Bitrix24 support and development.

When changing API versions, include product rows in integration migration map for REST 3.0 and recheck the set and totals.

Step 2

Account for the effects of set

According to the official documentation, crm.item.productrow.set replaces all rows with the supplied set. Omitted rows are deleted together with their corresponding payment rows, and the total is recalculated; an empty array leaves the object without products.

This action requires a snapshot of the set and verification of the intended differences in advance. For new development, also consider the documentation’s recommendation to use REST 3.0 crm.[type].productrow.replace.

Step 3

Do not confuse product IDs with row IDs

productId refers to the catalog, while id refers to an existing product row of a CRM object. The same product may appear in several rows with different terms.

To preserve a row’s identity, use its actual ID. Do not substitute the catalog ID for the row ID or treat matching names as proof that the row is the same.

Step 4

Pass commercial parameters explicitly

Check quantity, price, discount, tax and unit of measurement. The set description specifically notes that an omitted price is zero even when the catalog product has a price.

Compare totals in the same currency using the agreed calculation rule. Explain differences between a row and the overall total before writing, rather than after documents are issued.

  1. 01Scope

    Record the original state.

  2. 02Difference

    Perform the selected operation.

  3. 03Recalculation

    Confirm the saved result.

Set → Difference → Recalculation. Diagram of the integration verification scenario.
Step 5

Acceptance-test the result on a test order

Prepare a set with two products, an additional row and a manual edit. Test adding one row, updating an existing row and the intended full replacement.

After the operation, read the set, row IDs and total again. Keep the change plan and confirmed result in the log; repeating the command must not create an additional row.

Verification table

ControlDataExpected result
ControlAdd a rowDataNew row parametersExpected resultExisting rows are retained
ControlUpdate a rowDataRow ID and new fieldsExpected resultThe correct row has been changed
ControlReplace the setDataFull set and differenceExpected resultDeletions and the total are expected

Acceptance checklist

  • The meaning of the operation is defined
  • Catalog ID and row ID are different
  • The price is supplied explicitly
  • Rows to be removed are checked
  • The set has been read after writing

Frequently asked questions

Can set be used to add entries?

Only when the complete current set is supplied and replacement is actually required. Use add for a single new row.

Why did the price become zero?

Check price: the method is not required to supply the catalog price when it is omitted.

Is repeating add safe by itself?

Do not assume this. The application must check for an already created row using the operation key.

Need help automating the process?

We will review the original workflow, roles, data and exceptions. We will prepare a diagram, verifiable requirements and a safe Bitrix24 implementation plan.

Select service