<div dir="ltr">Hi,<div><br></div><div>I 've used an easyfix by doing this in my handleEvent:</div><div><br></div><div><div>      $modulename = $data->getModuleName();</div><div>     <span class="" style="white-space:pre">    </span>if ($data && $modulename == 'Invoice') {}</div></div><div><br></div><div>But i don't think this is the best way of doing this.</div><div>Does anyone know the right way of only handling this event on the Invoices aftersave ?</div><div><br></div><div><br></div><div>Thanks in advance!</div><div><br></div><div>Kind regards,</div><div><br></div><div>Lennart</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-12-25 2:40 GMT+01:00 Lennart van Ballegoij <span dir="ltr"><<a href="mailto:lennart@egmmedia.nl" target="_blank">lennart@egmmedia.nl</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div><span style="font-size:12.8px">I've been working on a Vtiger module that sends the data of a saved Invoice to a third party API.</span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I'm using a Event Handler to retrieve the data from the Invoice module and process it to send it to the third party API.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">After finishing the module i started testing it and it worked great except for returning empty </span><span style="font-size:12.8px">entry's  </span><span style="font-size:12.8px">to the database from time to time.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">When i looked into what caused the empty entry's i found out that it was caused by the save of other modules.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">But i thought the Event Handler will only run for the Module that was registered in the </span>Vtiger_Event::register ?</div><div><br></div><div>Is this not the case or am i just doing something wrong ?</div><div><br></div><div>My Vtiger event register code:</div><div><br></div><div><div>        public function registerInvoiceEvent(){</div><div>            if(Vtiger_Event::hasSupport()) {</div><div>                  Vtiger_Event::register(</div><div>                        'Invoice', 'vtiger.entity.aftersave',</div><div>                        'ReeleezeeHandler', 'modules/Reeleezee/ReeleezeeHandler.php'</div><div>                  );</div><div>            }</div><div>        }</div></div><div><br></div><div>My Event handler code:</div><div><br></div><div><div>class ReeleezeeHandler extends VTEventHandler {</div><div><br></div><div><span style="white-space:pre-wrap"> </span>public $helper = null;</div><div><br></div><div><span style="white-space:pre-wrap">   </span>public function __construct(){</div><div><span style="white-space:pre-wrap">          </span>require 'modules/Reeleezee/Helper.php';</div><div><span style="white-space:pre-wrap">          </span>$this->helper = new Reeleezee_Helper();</div><div><span style="white-space:pre-wrap">        </span>}</div><div><br></div><div><span style="white-space:pre-wrap">      </span>  function handleEvent($eventName, $data) {</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap">   </span>        if($eventName == 'vtiger.entity.aftersave') {</div><div><span style="white-space:pre-wrap">        </span>        <span style="white-space:pre-wrap">    </span>if ($data) {</div><div><span style="white-space:pre-wrap">     </span>            <span style="white-space:pre-wrap">      </span>$moduledata = $data->getData();</div></div><div>                        //More code here but don't think it's relevant</div><div>                }</div><div>          }</div><div>}</div><div><br></div><div>Can anybody give me a push in the right direction for why this is happening ?</div><div><br></div><div><br></div><div>Thanks in advance!</div><div><br></div><div><br></div><div>Kind regards,</div><div><br></div><div>Lennart</div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div></div>
</blockquote></div><br></div>