[Vtigercrm-developers] Invoice Items get unassigned by Workflow

EGM Media | Lennart van Ballegoij lennart at egmmedia.nl
Sun May 1 20:35:47 GMT 2016


Hey Guys,


I've got a strange problem that i can't seem to understand, hopefully
someone can help me out.


*The situation:*


I created an custom module"ControlBarcode" that is used by my client to
scan barcodes on Sales orders.

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)


I created a barcode that creates an Invoice when the code is scanned, this
all seems to work without any problems.

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.

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.

This Eventhandler gets ran after every Invoice save but only preforms an
action when the custom field in the invoice is set to "SENDTOREELEEZEE".


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.

This Workflow checks if a custom field is filled if so it will preform
actions and then trigger the next workflow and so on.

When the last Workflow got triggerd we change the custom field in the
invoice to "SENDTOREELEEZEE" so the Eventhandler can preform it's task.


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.

I'm using the following code in my Eventhandler to check for the assigned
products:

$invoicedata['invoiceid'] = $data->getID();

$query = $adb->pquery("select productid, quantity, listprice from
vtiger_inventoryproductrel where id =
?",array($invoicedata['invoiceid']));




The strange part is that if i check the Invoice after all these Workflows
get ran that the Invoice does contain products.

Also if i run the db query after these Workflows get ran the query does
retrieve the right products.


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.

I *attached a image* to this email to visualize the tasks the invoice goes
through before the error occurs.


Hopefully someone can help me out.

Thanks in advance!


Kind regards,

Lennart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20160501/2b612aa8/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Workflows.png
Type: image/png
Size: 303915 bytes
Desc: not available
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20160501/2b612aa8/attachment-0001.png>


More information about the vtigercrm-developers mailing list