[Vtigercrm-developers] Workflow on entity delete?

Max Clarke max at smarte.com.au
Tue Mar 25 01:23:46 GMT 2014


For those interested, to fire an event when an entity is unlinked from its
parent, add the following to include/utils/utils.php at line 1394:

require_once("include/events/include.inc");
$adb = PearDatabase::getInstance();
$em = new VTEventsManager($adb);
$em->initTriggerCache();
$entityData = VTEntityData::fromEntityId($adb, $record);
$em->triggerEvent("vtiger.entity.beforeunlink", $entityData);

and then for an event fired after unlink, after this line just under what
you inserted at 1394:

$focus->trackUnLinkedInfo($return_module, $return_id, $module, $record);

add the following:

$em->triggerEvent("vtiger.entity.beforeunlink", $entityData);

Cheers

Max



On Tue, Mar 25, 2014 at 11:02 AM, Max Clarke <max at smarte.com.au> wrote:

> Just a little more on this, after the event not firing and me tracing
> around the vtiger source...
>
> I realised that when you delete an entity from a related list it merely
> unlinks it, not deletes it.
>
> This might be intended behaviour, but from an end user standpoint, doesn't
> make much sense. Usually when you click a trash can icon and it pops up and
> prompts you "Are you sure you want to delete?", you think the entity will
> be deleted, not unlinked. Perhaps you need 2 buttons instead of 1 - one to
> delete which will be actually delete the object, and one to remove it from
> it's parent (unlink).
>
> Anyway, unfortunately there's no event that fires on this unlink method,
> so if anyone has any ideas besides modifying the core source to fire an
> event, I'm all ears!
>
>
> On Tue, Mar 25, 2014 at 9:08 AM, Max Clarke <max at smarte.com.au> wrote:
>
>> Unfortunately those aren't in the vtlib manual or on the Eventing Vtiger
>> page: https://wiki.vtiger.com/index.php/Eventing
>>
>> Thanks for the tip though, that'll do the trick!
>>
>>
>> On Mon, Mar 24, 2014 at 5:10 PM, Joe Bordes <joe at tsolucio.com> wrote:
>>
>>>  Not a workflow but you have two events to create eventhandlers:
>>>
>>> beforedelete
>>> afterdelete
>>>
>>> you can read on how to create eventhandlers in the vtlib manual
>>>
>>> Joe
>>> TSolucio
>>>
>>>
>>> El 24/03/14 04:22, Max Clarke escribió:
>>>
>>> Hi guys,
>>>
>>>  Hopefully an easy one. Is there a way to execute a workflow when an
>>> entity is deleted?
>>>
>>>  The reason I ask is so I can update a field in Tickets when a custom
>>> submodule entity is deleted.
>>>
>>>  Cheers
>>>
>>>  Max
>>>
>>>
>>> _______________________________________________http://www.vtiger.com/
>>>
>>>
>>>
>>> _______________________________________________
>>> http://www.vtiger.com/
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20140325/c747fdb4/attachment.html>


More information about the vtigercrm-developers mailing list