Have you ever needed the ability to stop a record from saving in Extender based on some criteria? You have, well so have we! We added the ability to Extender Enterprise 2016 (version 16.00.0030 and higher) and Extender Enterprise 2018.

While we cannot stop the save process of every process, we have added the ability to do a “Pre Save Record” task and set a global value to stop the save from continuing in any Extender window. In this example, we have a GL transaction and need to split out the distribution amount to additional categories. Think a poor man’s analytical accounting system.  We created an Extender window off the GL Transaction Entry Window to track the additional categories. I have a separate task to populate the Amount to Distribute when the extender window opens.

When I click save, I want the “Amount to Distribute” to match the “Amount” total at the bottom of the scrolling window. If the amounts match, then we can save the record. If the amounts do not match, then I do not want the user to be able to close the window without these being in balance.

 

We start by clicking the Action button on the Extender Window setup window.

Click Add


Select Pre Save Record event type, click add and select Run Dynamics GP Script

Enter a description, select the product of Extender.

Here is the code you would want to use as an example.

 

if Total of window ‘User Defined Window’ of form <#FORM_NAME#> <> <Amount To Distribute> then

  warning “Total must match”;

  ‘Abort Save’ of globals = true;

else

  ‘Abort Save’ of globals = false;

end if;

 

We need to set the ‘Abort Save’ of globals to true to stop the save from finishing. One thing to remember: always set the ‘Abort Save’ of globals to false when you want the save to continue or you could get yourself stuck in the extender window on save since the ‘Abort Save’ of globals was set to true if the Total did not equal the Amount To Distribute field. Once you get the amounts to match, the ‘Abort Save’ of globals would still be set to true since your code did not set it to false to continue the save. No need to cause yourself more pain than needed.

 

Happy Coding!