Tuesday, 16 January 2018

How to check custom validation on purchase order confirmation event in AX7 / D365

There are scenarios where we need to do some custom validations on the purchase order while we try to confirm the PO.
In AX7 / D365 we can use the pre-post events in order to achieve our goal.

For the purpose of validation on purchase order confirmation we use the following event :






The reason of using post event handler of method "validate" of class PurchFormLetter_PurchOrder is that the system runs its default validations first and then we check for our custom validations.

The "validate" method of class PurchFormLetter_PurchOrder is generic, so we first need to capture if the flow of the code occurs from the confirmation class of the purchase order:








Now we do our validations in this "if " check and we need to stop the confirmation of PO in case of failure of our custom validations:











and in case of successful custom validations :


How to block inventory in ax D365 / AX7

In Dynamics AX if we want to block inventory for certain item, we have an out of the box form which caters this need and blocks the inventor...