Inserting a Script for Standard Processes

To quickly generate VB.NET script for frequently used tasks, click the Insert Script button on the Script Editor page. The following options are available:

Here you can view an example of generated script.

For example, you may wish to specify the exact nature of the export within the log, which cannot be inferred by the file name. Here is some sample code generated by the Insert Script feature to do this:

Log.AddEvent("Monthly General Ledger Export")

Note: The available alerts are the user-defined alerts listed on the Automator Alerts page.

  1. In the Text field enter the text you want displayed for the alert.

  2. Click Insert to add the script.

Here is some sample code generated by the Insert Script.

If Shell("""c:\test.bat""",AppWinstyle.Hide,True,10000) <>0 Then

'TODO: Handle command timeout here.

End If

 

NOTE: Command lines are executed by the .NET service, which for security reasons does not allow the application to show a user interface. Please ensure that any command lines or applications you run do not require a user interface and shut themselves down after completion. In addition, be sure to specify a timeout value after which Automator will kill the offending process if you do not want Automator to hold up processing altogether. If no timeout is specified, Automator will wait forever until the command line returns. If you specify a timeout that is exceeded, then you can deal with that condition in your script.

 

Here is some sample code generated by the Insert Script.

In the following example, the feature has been combined with the raise alert feature to raise an alert called Summary Exception if any of the projects contained a summary exception as defined by the model's summary exception coloring rules.

First, the Test for Data Exceptions was chosen with an option of "All Projects" to give a script of :

If Log.HasExceptions() Then

TODO: Perform desired operation if exceptions were found.

End If

Second, the whole line containing the TODO: was highlighted and the Insert Script To| Raise an Alert was chosen with the Alert Name of "Summary Exception" and the Alert text of "A summary exception has occurred". This produces the final script of:

If Log.HasExceptions() Then

Log.AddEvent("A summary exception has occurred", "Summary Exception")

End If

Now you can define the actions for this alert on the Alerts page of the Automator.

Note: You must have already defined summary exception coloring rules in your Monarch model in order for this feature to work.