method call after PurchFormLetter of invoice

I have created a method that i need to be executed right after the Purchase invoice has been completely posted and updated. i tried calling the method on the Click() of the Ok button of the form. but it didnt work, method was executed before the vendor and inventory transactions were updated.

any advice is much appreciated :slight_smile:

Placing your code in clicked() method in this case doesn’t seems to be good.

You need to place your logic in PurchFormLetter_Invoice class, where actually the inventory updation and other task like creating journal tables, printing them and creating parm tables etc… will happen. Put a debugger and find the location to place your code based on the requirement.

Hi Lola,

Can you please tell that which was the form on which you placed the code? Was it the “PurchEditLines” form which gets opened when you click the “Invoice” menuitembutton? If it is so than your method will be executed before the actual invoice posting as the “PurchEditLines” form is itself called by the class “PurchFormLetter_Invoice” before the actual invoice posting is done. You will have to trace carefully using the debugger that where the actual invoice posting is done by the code of the class “PurchFormLetter_Invoice” and then depending on your requirement you’ll have to place your code/method at the appropriate place .

hiii Lola,

You have to define your code in the UpdateNow() method of PurchFormLetter_Invoice class…