Codeless - Setting relationship in Transaction API

I am trying to set relationships in an API function an I am getting the following error:

“Unable to perform ‘ADD_RELATION’ operation due to argument incompatibility. The operation references a result from another ‘UPSERT_BULK’ operation. The specified result cannot be obtained from this operation (objectId).”

The function I am trying to create takes a list of sales transactions and saves them into 3 different tables. These tables will need relationships to link to each other.

I have included a screenshot of my code blocks below, the problem area is highlighted with the red square.

I initially tried using a “bulk upsert operation” on the line_item table but the “create operation” inside a for loop is the option pictured. Both options produce the same error.

If I remove the relations blocks from the function the records are saved to the database successfully.

The list of objects I am splitting looks like this:
“selling_price”: 404,
“url”: “”,
“quantity”: 2,
“sale_status”: “Shipped to Customer”,
“url_mobi”: “”,
“offer_id”: 53170421,
“product_title”: “ET-Blu Mix 2 Button Remote - Blue”,
“order_item_id”: 126169025,
“order_date”: “2021-04-05 18:00:00”,
“tsin”: 44054365,
“sku”: “A0807x001”,
“order_id”: 86101273,
“dc”: “JHB”,
“customer”: “Lawrence Dipudi”
Any assistance would be most welcome.

Hello @Mark_Wilson1
The problem is that the operation reference of “bulk upsert” operation doesn’t work in the “Add relation” operation “children” property. Now I don’t know why. We will investigate this case if it is possible.

There is an incomplete workaround: What if use two transactions. First for “bulk upsert” operations. The second transaction with “create” and “Add relations” operations. With a list of object ids in the “add relations” operation children from the result of “bulk upsert” transactions?

But if your “list_of_inventory” “list_of_sales” lists with objects which have objectId, you can use these object ids in a list for “add relation” children property


Thank you @viktor.liablin

I have managed a work-around by adding the updated objectId to the “list_of_items” etc and then completing a for loop to add the relations.

It seems to work.


Yeah, “Bulk upsert” does not work correctly.
I’ve created an internal ticket BKNDLSS-28429 to fix it.
But instead of “bulk upsert” you can use “bulk create” or “bulk update”.