Invoice validation trigger getting (PROVxxxx) instead of the final number

Hi guys!

I’m running 15.0.00.

I made my first module using the builder. Validating an invoice triggers a script which creates an invoice object to my accounting agency’s system so I don’t have to create all the invoice lines manually.

The problem is that when I validate my invoice the FIRST TIME, the invoice REF passed to my script is still (PROVxxxx). It should be like 123456. I can fix it by modifying and re-validating, and then it works.

So I guess the trigger runs before the invoice gets validated, and the “old” ref is passed to the runTrigger in $object->ref.

Is there any way to get the invoice number, which is about to be given to the invoice? The system knows it already at that point, because is is visible in the “Do you want to validate…” -dialog.

Thanks in advance for your help!

Hi, I‘m also working on output some stuff like proposals, orders and invoices to an external system via triggers.
I think you can use $object->newref instead of $object->ref.

Bye,
Bernd

Indeed! I tried to look it from all the non-obvious places, and there it was right under my nose all the time…

Thanks Bernd!