Codeunit 415 - Release Purchase Document - OnAfterReleasePurchaseDoc - question
How can we put validations on the subscribed event which are raised and published within Base Code.
For Ex : I have a scenario where i have to execute some code in Codeunit 415 - Function Code and Published Event - OnAfterReleasePurchaseDoc. Now if i subscribe the function and write my code in AL then it will be executed in both the scenarios, when Releasing the Document from PO and Releasing Source Document from Warehouse Receipt. My question is how am i supposed to stop the execution of my code in AL when document is released from Warehouse Receipt without leaving any footprints in Base NAV.
One way i found is to Create a Single Instance Codeunit, save a certain parameter which can be later fetched to determine the process from where the code is executing. Is there any other way?
Hi, Any help, will be appreciated.
Hi, Any Suggestions, Please.
Difficult to answer in details without knowing what you are doing from WMS part, you can use fields in extension or use events in WMS part. Codeunit 415 in general is now aware about origin of call.
Hi Alexander. Thanks for replying. Apologies for not providing details here. There are 2 ways with which we can release and post a purchase order.
First we can create a Purchase Order Manually from Purchase Order Page, release and post the same.
Second if its a Warehouse location then Create the Purchase Order from purchase order page and fetch on a Warehouse Receipt, Release the document from Warehouse and Post the same. If we don't release the document and directly post it the system automatically triggers the Release related code.
Now my query is both the code snippets calls codeunit 415 to release the Purchase Order and there is some code i have written by subscribing to OnAfterReleasePurchaseDoc method of the very same codeunit. I want this code to be executed only if the Purchase Order is created, released and posted from the Purchase order Page (using first scenario). Is there a way on 415 to distinguish between the two different calls ?
This question goes for all scenarios where two Source Points are Pointing to One Destination Point and we want to make sure that our code executes when process starts from one Source Point and shouldn't when started from another.
You have source fields in Warehouse Receipt Line and can check if PO has related Whse, Receipt lines in your code.
Agreed. That's something that i did. Was thinking if there is anything else, because this kind of scenario can come up for any other codeunit where we may not have field references to map the difference between processes. Earlier we used to set a Boolean on the Codeunit and based on that the decisions of executing a code is made, now as we can't touch the base codeunits what could be the best solution ?
Hi All, Any Suggestions for the Mentioned Query?
This is your solution and opportunity to identify best solution. I'm available to implement new events if you need any.
Thanks for replying. Seems like the only solution where there are no field references is to create Single Instance for no traces. Will be closing the Issue.