I've been able to initialize an invoice from a sales order using 2012 PHP Toolkit (see code below). The invoice object returned looks fine.
However, when I try to add the invoice, I'm getting
INSUFFICIENT_PERMISSION
You do not have permissions to set a value for element subtotal due to one of the following reasons: 1) The field is read-only; 2) An associated feature is disabled; 3) The field is available either when a record is created or updated, but not in both cases.
I've read the Platform Guide examples for setting ignoreReadOnlyFields in other languages, and in posts for PHP for pre-2012 endpoints. But, what I've tried for the 2012 PHP Toolkit 2012 has not yet worked. I can see the preference is not getting set in the header. The only header fields seem to be the ones set in NSconfig.php
Any advice for this newbie greatly appreciated about how to set this preference.
require_once '../PHPToolkit/NetSuiteService.php';
$service = new NetSuiteService();
$prefs = new Preferences();
$prefs->ignoreReadOnlyFields = true;
$service->preferences = $prefs;
$netsuiteOrderId = "xxxxxxx";
$so = new InitializeRef();
$so->type = 'salesOrder';
$so->internalId = $netsuiteOrderId;
$initializeRecord = new InitializeRecord();
$initializeRecord->type = 'invoice';
$initializeRecord->reference = $so;
$request = new InitializeRequest();
$request->initializeRecord = $initializeRecord;
$initializeResponse = $service->initialize($request);
if ($initializeResponse->readResponse->status->isSuccess)
{
$invoice = $initializeResponse->readResponse->record; /* works */
$invoiceRequest = new AddRequest();
$invoiceRequest->record = $invoice;
$addResponse = $service->add($invoiceRequest); /* gives error */
if (!$addResponse->writeResponse->status->isSuccess)
echo 'Did not work '; /* seeing a lot of this */
else
echo 'Successfully added invoice';
}