Removing LineItem from SalesOrders with the PHP SDK

Removing LineItem from SalesOrders with the PHP SDK

Hello,

I am having some trouble trying to remove a LineItem entry from a SalesOrders record via the PHP API. Here's how I'm trying to do it:

$salesOrders = ZCRMModule::getInstance("Sales_Orders");
/** @var ZCRMRecord $salesOrder */
$salesOrder = $salesOrders->getRecord(3841630000000284001)->getData();

$newItems = [];
$salesOrder->setFieldValue('Subject', 'Test change');
/** @var ZCRMInventoryLineItem $item */
foreach ($salesOrder->getLineItems() as &$item) {
$item->setDeleteFlag(true);
}

$response = $salesOrder->update();

var_dump($response->getResponseJSON());

The response says that the changes are successful and the 'Subject' field does change as expected, but the product lines are unchanged.

A previous question ( https://help.zoho.com/portal/community/topic/remove-an-invoice-line-item-via-api) hints that this is how it should be done, but it doesn't seem to be working in my case.

What am I doing wrong?