MoneyWorks is an extremely powerful accounting and business information system, but, a bit like a politician, it can please some of the people all of the time, and all of the people some of the time, but it can't please all the of the people all of the time. Scripts and Automation allow you, the people, to extend the functionality of MoneyWorks, so you can get it to please you all of the time.
Automation is a technology that was implemented in MoneyWorks 2 (about 1997), when it was realised that MoneyWorks needed to talk to other programs running on your computer, or that you wanted to extend the capabilities somehow. The first script was the famous “PickleOdeon”, developed for a pickle manufacturer to help manage his pickle recipes.
Automation basically allows other systems to extract information from, or submit information to, MoneyWorks. Imagine if your costing spreadsheet could get the cost prices direct from MoneyWorks, or your CRM system could update customer information in MoneyWorks at the press of a button. Both these have been possible since the early 2000s. Automation capabilities were substantially increased in MoneyWorks 6.1 by the implementation of the REST APIs, which allow access to MoneyWorks Datacentre from remote devices over the internet.
Scripts are a new technology, introduced into MoneyWorks Gold in the MoneyWorks 7 release (and not available in Express or Cashbook). Scripts allow you to automate certain operations in MoneyWorks, and can also change the way that MoneyWorks interacts with the user. For example, when you enter an item code into a quote, MoneyWorks will normally get the price from the item details stored in MoneyWorks. With a script, it could get the price from somewhere else, perhaps even look it up on your suppliers web site. Similarly you may want to implement your own pricebook, with possible separate prices for selected items per customer. Scripting makes this possible, without even needing to leave the comfort of MoneyWorks.
Scripts can also be used to manage cusomt controls for report settings, and also provide “library functions” for the report (see the Cash Projection Report for an example).
Scripts allow you to automate operations within MoneyWorks. They can read external files (either from your local volumes, or from a web server), intercept user-interface actions, create and update records and more.
A number of sample scripts are included in the Acme Widgets sample file. These are turned off by default, but you can easily turn them on to see how scripts work, and to play with the scripting language.
You can access the scripts by:
The Scripts Management window will open.
The first time you do this the scripts window will be empty. In the example above, there are three scripts (listed down the side). The “test” and “external” scripts are activated (indicated by the green tick), whereas the “Pricebook” script is deactivated, so will not run (indicated by the red cross).
To view a particular script:
- Click on the script in the sidebar
The script contents will be displayed in the body of the window, where it can be edited. If you do edit a script, you will need to activate it again (see below).
To activate a script
- Select the script in the sidebar by clicking it (if it is not already selected)
- Click the Activate toolbar icon
A green tick will appear next to the script on the sidebar indicating that it has been activated. If there is a syntax error in the script (i.e. some invalid text that the script compiler doesn't recognise), the script will not activate, and a tooltip will alert you to the error and where it occurs (and the part the script at and following the error will be coloured orange).
To deactivate a script
- If the script is not the currently selected one, click on it in the sidebar
- Click the Deactivate toolbar icon
If the script has an Unload handler, it will be called.
After the script is unloaded, a red cross will appear next to the script's name in the sidebar indicating that it is no longer active.
Note: If the script contains a public handler, any other scripts that use that handler will also be deactivated.
Usually, scripts will implement Handlers that allow the script to respond to certain user actions (like opening a window for a record, clicking a custom toolbar icon, or tabbing out of a particular field). The Load handler can be considered the main entry point of a script in that Load is called when you activate the script or the script is auto-activated when you log in to the document.
If you want a script to just do one thing, the Load handler is the place to do that thing. Having activated the script and had the Load handler execute, keep in mind that the script stays loaded, and the Load handler will execute the next time you (or anyone else) logs into the document. If you don't want this, you should deactivate the script.
Asterisk in window title indicates script activity
When a window has a script handler associated with it (and the handler has actually been called at least once), the window title will have an asterisk appended to it. If you have any unusual behaviour in a window, the asterisk is a clue that the behaviour is probably due to a script acting on the window.