[Vtigercrm-developers] Updating Inventory records using record model clears off the lineitems

nilay khatri nilay.spartan at gmail.com
Fri Apr 20 05:27:38 GMT 2018


Thanks Maggi.

I shall try that as well.

For now setting up the value for productid as the id of first Product in
lineitems and vtws_update works fine for me.



On Fri, Apr 20, 2018 at 3:11 AM, Conrado Maggi <comaggi at gmail.com> wrote:

> The only way I've make it work was.
>
> 1) vtws_retreive and pull all the record information
> 2) Override the array with the new values
> 3) vtws_revise the entire array.
>
> In the mod tracker only show up the new values from #2 and you avoid both
> issues.
>
> Conrado
>
> On Thu, Apr 19, 2018 at 5:08 PM, nilay khatri <nilay.spartan at gmail.com>
> wrote:
>
>> Yeh saw that.
>>
>> Another way was to use webservice APIs. Though there got an exception
>> that mandatory field productid is missing.
>>
>> Following code resolved it:
>>
>>
>>                 global $current_user;
>> $id = vtws_getWebserviceEntityId('Invoice',$vtigerInvoiceId);
>> $record = vtws_retrieve($id,$current_user);
>> $record['fieldname'] = 'fieldvalue';
>> $record['productid'] = $record['LineItems'][0]['productid'];// solution
>> to set value for productid
>> vtws_update($record,$current_user);
>>
>>
>>
>> On Thu, Apr 19, 2018 at 8:33 PM, Alan Lord <alanslists at gmail.com> wrote:
>>
>>> Look through the archives of this list for my thread called "Inventory
>>> Record copying" (November 2017) - that might help you.
>>>
>>> Al
>>>
>>>
>>>
>>>
>>> On 19/04/18 14:43, nilay khatri wrote:
>>>
>>>> Hi,
>>>>
>>>> I am trying to update an Invoice using Record Model, somewhat like:
>>>>
>>>> $invoiceRecordModel = Vtiger_Record_Model::getInstan
>>>> ceById($vtigerInvoiceId);
>>>> $invoiceRecordModel->set('fieldname','fieldvalue');
>>>> $invoiceRecordModel->set('mode','edit');
>>>> $invoiceRecordModel->save();
>>>>
>>>> But doing so removes all the lineitems. Any hints on how to update
>>>> without removing lineitems?
>>>>
>>>>
>>>> _______________________________________________
>>>> http://www.vtiger.com/
>>>>
>>>>
>>>
>>> _______________________________________________
>>> http://www.vtiger.com/
>>>
>>
>>
>> _______________________________________________
>> http://www.vtiger.com/
>>
>
>
> _______________________________________________
> http://www.vtiger.com/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20180420/67d6c1db/attachment.html>


More information about the vtigercrm-developers mailing list