[Vtigercrm-developers] Event handlers add/update distinction

Prasad prasad at vtiger.com
Fri Jan 7 01:31:07 PST 2011


Done.
http://wiki.vtiger.com/index.php/vtiger510:Eventing#isNew

On Fri, Jan 7, 2011 at 1:35 PM, Darjan Prtic <dprtic at gmail.com> wrote:

> I already made changes to my code. Now i have to change it again. :)
>
> Thanks Prasad.
>
> This should be documented in Eventing wiki.
>
> Regards,
> Darjan Prtic
>
>
> On Fri, Jan 7, 2011 at 08:18, Prasad <prasad at vtiger.com> wrote:
>
>> Darjan,
>>
>> The event handler parameter will have the information
>> about the record mode as depicted below:
>>
>> class MyModuleEventHandler extends VTEventHandler {
>>     function handleEvent($eventName, $data) {
>>         if ($data->isNew()) {
>>             // Create of new record
>>         } else {
>>             // Edit of older record
>>         }
>>     }
>> }
>>
>> Regards,
>> Prasad
>> vtiger Team
>>
>> On Fri, Jan 7, 2011 at 11:45 AM, Darjan Prtic <dprtic at gmail.com> wrote:
>>
>>> Hi!
>>>
>>> Is there a way using event handlers to distinct when some record is being
>>> updated (edited and then saved) and newly added?
>>> When new record is saved i make relations in vtiger_crmentityrel table by
>>> inserting corresponding crmid of that module and contact, also vice versa. I
>>> do that in aftersave event because i need crmid of record that is being
>>> created. That works fine. But now i have a problem when i just edit that
>>> record and save it. New, unnecessary insert is being made to
>>> vtiger_crmentityrel table with already existing values. What should be done
>>> is _only_ update if necessary.
>>>
>>> I use vtiger 5.10.
>>>
>>> Thank you!
>>> Darjan Prtic
>>>
>>> _______________________________________________
>>> 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/20110107/1e7e06b2/attachment-0002.html 


More information about the vtigercrm-developers mailing list