Hi all,
In the codeunit that releases a Transfer document, it does the following:
VALIDATE(Status,Status::Released)
We have an addon (Chargelogic Shipping) that has added some event trigger code in the OnAfterValidate event. It does, among other things, a TESTFIELD command. We've observed if this TESTFIELD fails (generating a message), that the Status field still changes.
So, my question is: Can anyone confirm that an error generated in an OnAfterValidate event does NOT cause the VALIDATE to fail? It would seem reasonable that this is the case, but I'd sure like to know.
Thanks
Ron
Ron
0
Answers
EDIT: The above is incorrect, please see later post below...
Hmmmmmm.....
I now understand that You are actually talking about events like OnBeforeValidate and OnAfterValidate - and I totally agree with you and Mark - any changes in these 2 events would be in the same transaction as changes to the original OnValidate trigger and so an error in any of these should cause changes to rollback.
This does seem like a bug so I would test in the latest build and if it's still a problem then report to Microsoft. Apologies for the initial confusion.
which CU are you using?
or can you show event code?
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
...in the "other things" it does, it doesn't by any chance do a COMMIT does it? That would certainly explain what's happening.
If not INSERT(TRUE) then
ERROR('....
would function as expected.
Try to chang ethe code to
IF MYFIELD <> "Value" THEN
ERROR("...;
This will let you know if its a Nav bug, or if there is something wrong in your code.
In the Addon's event trigger, there is a COMMIT before the TESTFIELD - we are still trying to determine if this results in the out-of-sync condition that we are observing, but it does appear that the COMMIT overrides the update transaction's integrity from "end-to-end".
Ron
The question is should there really be a COMMIT in the OnAfterValidate event?.... I'd say this is not a great idea as it would cause problems as you have discovered.
Ron
To be clear COMMIT will not "override transactional integrity" - if you are using the CONSISTENT command to enforce transactional integrity and a COMMIT is encountered (even in an event) the transaction will fail if the database is not in a consistent state.
You need to explain the situation to the addon provider demonstrating how it is causing a problem and get them to remove the COMMIT from their subscribed event. At the end of the day their code is causing bug (status being changed even though an error occurs) so it's up to them to fix it.