[Vtigercrm-developers] add/remove relatedlist entry trigger eventhandler

Mariusz Krzaczkowski m.krzaczkowski at yetiforce.com
Thu May 21 18:52:20 GMT 2015


 

Hi all,
What you need it is very easy to do this, just add a simple trigger
handler, here's an example: 

https://github.com/YetiForceCompany/YetiForceCRM/blob/master/include/utils/utils.php#L1646
[1] 

and 

https://github.com/YetiForceCompany/YetiForceCRM/blob/master/include/utils/utils.php#L1651
[2] 
---

Z poważaniem / Regards 

MARIUSZ KRZACZKOWSKI 
_Director of Product Development_ 
M: +48 884-998-123
E: m.krzaczkowski at yetiforce.com 
-------------------------

We created an innovative open source project called YetiForceCRM. You
can test it here [3], download [4] it for free or read its documentation
[5]. Follow us on Twitter [6] to get real-time info about new
functionalities and articles. 

 		TEMAT:
 		[Vtigercrm-developers] add/remove relatedlist entry trigger
eventhandler

 		DATA:
 		2015-05-21 18:17

 		OD:
 		Alan Lord <alanslists at gmail.com>

 		DO:
 		vtigercrm-developers at lists.vtigercrm.com

 		ODPOWIEDŹ DO:
 		vtigercrm-developers at lists.vtigercrm.com

I need to have an EventHandler which fires when a module has a record
either added or removed from it's related list in vtiger_crmentityrel.

 Mod Tracker seems to be able to detect these events because the changes
get written to the ModTracker tables and diplay in the Updates summary
widgets etc...

 However, having looked at the ModTracker Event Handler code, and
registered a test handler I cannot get it to fire at all...

 I've registered it with:

> $em-⁠>registerHandler('vtiger.entity.aftersave.final', 'modules/⁠LSContracts/⁠resources/⁠LSContractsEventHandler.php', 'PeakDemandEventHandler');

 And my test code is:

> class PeakDemandEventHandler extends VTEventHandler {
> 
> function handleEvent($eventName, $data) {
> global $log, $current_module, $adb, $current_user;
> require_once 'data/⁠VTEntityDelta.php';
> 
> $moduleName = $data-⁠>getModuleName();
> 
> $log-⁠>debug("In " . __CLASS__ . " " . __FUNCTION__);
> 
> if($eventName == 'vtiger.entity.aftersave.final') {
> $recordId = $data-⁠>getId();
> $columnFields = $data-⁠>getData();
> $vtEntityDelta = new VTEntityDelta();
> $delta = $vtEntityDelta-⁠>getEntityDelta($moduleName, $recordId, true);
> 
> $log-⁠>debug("EntityDelta: " . print_r($delta,true));
> }
> }
> }

 this fires if I change a *field* in a module, but it doesn't trigger if
I change a relationship in the crmentityrel table by either selecting or
deleting a record from the Related List... How can I do this please?

 Thanks

 Al

 _______________________________________________
http://www.vtiger.com/ [7] 

Links:
------
[1]
https://github.com/YetiForceCompany/YetiForceCRM/blob/master/include/utils/utils.php#L1646
[2]
https://github.com/YetiForceCompany/YetiForceCRM/blob/master/include/utils/utils.php#L1651
[3] https://test.yetiforce.com/
[4] https://github.com/YetiForceCompany/YetiForceCRM
[5] https://yetiforce.com/en/documentation.html
[6] https://twitter.com/YetiForceEN
[7] http://www.vtiger.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20150521/debc72b3/attachment.html>


More information about the vtigercrm-developers mailing list