<div dir="ltr">Hey Guys,<div><br><div><br></div><div>I've got a strange problem that i can't seem to understand, hopefully someone can help me out.</div><div><br></div><div><br></div><div><b>The situation:</b></div><div><b><br></b></div><div><br></div><div>I created an custom module"ControlBarcode" that is used by my client to scan barcodes on Sales orders.</div><div><br></div><div>When scanned it retrieves the Sales Order and displays this to the client, the client can then scan 1 of the control Barcodes to preform a action on the Sales Order (Like: changing a field to a preset value)</div><div><br></div><div><br></div><div>I created a barcode that creates an Invoice when the code is scanned, this all seems to work without any problems.</div><div><br></div><div>But after the Invoice is created i need to run a couple of workflows and after those workflows are complete the Invoice needs to be send to a Web-service.</div><div><br></div><div>To send the Invoice to a Web-service i created a custom module that uses an Eventhandler to preform the call to the Web-service.</div><div><br></div><div>This Eventhandler gets ran after every Invoice save but only preforms an action when the custom field in the invoice is set to "SENDTOREELEEZEE".</div><div><br></div><div><br></div><div>I created a couple of Workflows with the help of Workflow Designer(a third party module) they get triggerd by 1 initial workflow than gets triggerd on an 'on every save' event.</div><div><br></div><div>This Workflow checks if a custom field is filled if so it will preform actions and then trigger the next workflow and so on.</div><div><br></div><div>When the last Workflow got triggerd we change the custom field in the invoice to "SENDTOREELEEZEE" so the Eventhandler can preform it's task.</div><div><br></div><div><br></div><div>Here is where my unexpected error occurs, the Invoice does not get send to the Web-service because it can't find any products assigned to the invoice.</div><div><br></div><div>I'm using the following code in my Eventhandler to check for the assigned products:</div><div><br>
<pre>$invoicedata['invoiceid'] = $data->getID();
<br>
$query = $adb->pquery("select productid, quantity, listprice from vtiger_inventoryproductrel where id = ?",array($invoicedata['invoiceid']));
</pre>
</div><div><br></div><div><br></div><div><br></div><div>The strange part is that if i check the Invoice after all these Workflows get ran that the Invoice does contain products.</div><div><br></div><div>Also if i run the db query after these Workflows get ran the query does retrieve the right products.</div><div><br></div><div><br></div><div>So for some reason the products get unassigned in the save event and never trigger a resave when the products get reassigned, therefore my Eventhandler can't preform the call to the web service.<br></div><div><br></div><div>I <b>attached a image</b> to this email to visualize the tasks the invoice goes through before the error occurs.</div><div><br></div><div><br></div><div>Hopefully someone can help me out.</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></div>