[Vtigercrm-developers] Saving an invoice - What am I doing wrong?
Hamono, Chris (DPC)
Chris.Hamono at sa.gov.au
Wed Dec 3 04:24:27 GMT 2014
I am programmatically updating a couple of fields in an invoice. When I save the invoice the changes are correctly recorded but it loses the attached product.
I am using the following code what am I doing wrong?
// create the model from the record id
$invoiceModel = Vtiger_Record_Model::getInstanceById($invoiceid, "Invoice");
if ($invoiceModel) {
// set the fields as supplied
foreach ($fields as $key=>$value){
$invoiceModel->set($key, $value);
}
// set mode to edit
$invoiceModel->set('mode', 'edit');
// save
$invoiceModel->save();
return $invoiceModel->getData();
}
If I var dump the array returned by getData() it correctly shows the product and the changes.
e.g.
['invoicestatus'] =>'Paid' <= status changed
['cf_738'] =>'BZ-0025028687' <= custom field being updated
['invoice_no'] =>'INV405'
['productid'] =>2175
['quantity'] =>1.000
['listprice'] =>605.00000000
If I then go to the invoice detail page. The changes I have made are correctly saved (in the above I am setting the status field to 'Paid' and setting a custom field) but the invoice no longer has any products attached to it.
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20141203/c9da2273/attachment.html>
More information about the vtigercrm-developers
mailing list