This is a Quick Tip post to explain how the Dexterity Reject Script command works.
The Reject Script command is designed to be used in trigger scripts to stop the original code from running. However, it only works in specific situations:
Note: The Reject Script command cannot be used to abort processing of original code for functions or procedures.
When the user interface (focus) event occurs, Dexterity creates a queue of the scripts to be run. This starts with the TRIGGER_BEFORE_ORIGINAL triggers for each of the products registered against the event, then the original event script, followed by the TRIGGER_AFTER_ORIGINAL triggers for each product registered against the event. For example:
So, in this example, only Scripts 1 or 2 can use Reject Script to "drop" the queue and stop any further processing.
Best practice is to only use Before Triggers for validation to confirm that the desired conditions are or are not met, or to capture data needed for the After Trigger code. You must use After Triggers to take actions once it is confirmed that the system will be executing the Original code and After triggers.
If you "perform actions" in the Before script, there are two potential problems that could happen (see script queue above):
Note: The order which triggers against the same event are run is based on the order that the triggers were registered. If the Startup global procedure is used to register the triggers (which is best practice), then the trigger registrations will be processed in the order the products are listed in the DYNAMICS.SET launch file. So re-ordering products in the DYNAMICS.SET launch file can change the sequence for trigger scripts.
I hope this information is useful to you.
Posting by Vaidy Mohan on Dynamics GP - Learn & Discuss
Posting from Mark Polino at DynamicAccounting.net
PLEASE READ BEFORE POSTING
Please only post comments relating to the topic of this page.
If you wish to ask a technical question, please use the links in the links section (scroll down, on right hand side) to ask on the Newsgroups or Forums. If you ask on the Newsgroups or Forums, others in the community can respond and the answers are available for everyone in the future.