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:

  • Add an event to the log: Select to add an event to the Job Log.

  • Specify the text to be added to the Job Log in the Event Text field and click Insert.

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")

  • Raise an Alert: Select to raise an alert for use with the alerts in the Automator. Specify the following settings:

    1. In the Name field, select the desired alert from those listed or enter of a new alert name.  

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.

  • Execute an external command line: Select to execute a command line application. This function allows you to specify the command line, the parameters, including Automator macros, and a timeout value for the command line. Specify the following settings:

    1. In the Command field, enter the command line text.

    2. In the Parameters field, specify the parameters to be passed to the program or batch file (you can also use the naming macros).

    3. Select one of the options:

      • No time limit: Specifies that a time limit for the command line to complete is not necessary. Note: If the command line does not complete, Automator will wait indefinitely until it completes or is terminated.

      • Timeout after n second(s): Sets the delay before Automator terminates the command line.

    4. 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.

 

  • Iterate through a list of input or output items (available only for project-scripting) - Select to run the script through a list of input or output items and specify whether you want to do it for data exceptions in the current project or in all projects. Specify the following settings:

    1. Type: input items (iterates through a list of input items) and output items (iterates through a list of output items).

    2. Scope: current project (iterates through items in only the current project) and all projects (iterates through items in all projects).

    3. Click Insert to add the script.

  • Iterate through the list of events: Select to iterate the script through the list of events in the job log. Simply click Insert to add the script.

  • Test for data exceptions  (available only for project-scripting): Select to specify whether you want to test for data exceptions in the current project or in all projects and click Insert to add the 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.

  • Set the value of a runtime field: Select to specify a value for a runtime field. Specify the following settings:

    1. In the Field Name field, enter the name of the runtime field.

    2. In the Field Value field, specify the desired value for the runtime field.

    3. Select one of the following:

      • Set this value unconditionally: Sets the value unconditionally, resulting in a simple call to SetRuntimeFieldValue.

      • Set this value only if a value for this field has not already been set: Sets the value conditionally, resulting in a call to SetRuntimeFieldValue that is contingent on a return of False from HasRuntimeFieldValue.

    4. Click Insert to add the script.

  • Export to MapR Hive table: Select to export data to MapR Hive table. Specify the following settings:

    1. Specify the target server information: Host Name or IP Address, Cluster Name and path to the HDFS Directory (if necessary).

    2. Specify the export information: Project ID and Export Name.

    3. To overwrite data in the existing table, select the Overwrite Table check box.

    4. Click Insert to add the script.

  • Export to HD Insight Hive table: Select to export data to HD Insight Hive table. Specify the following settings:

    1. Specify the target server information: Host Name or IP Address and path to the HDFS Directory (if necessary).

    2. Specify the export information: Project ID and Export Name.

    3. To overwrite data in the existing table, select the Overwrite Table check box.

    4. Click Insert to add the script.

  • Copy to HDFS MapR: Select to copy data to HDFS MapR.

    1. Specify the target server information: Host Name or IP Address, Cluster Name, Target Directory Path and Target File Name.

    2. Specify the export information: Project ID and Export Name.

    3. Click Insert to add the script.

  • Copy to HDFS HD Insight: Select to copy data to HDFS HD Insight. Specify the following settings:

    1. Specify the target server information: Host Name or IP Address, Target Directory Path and Target File Name.

    2. Specify the export information: Project ID and Export Name.

    3. Click Insert to add the script.

  • Insert: Inserts the current pre-export script into the script field.

  • Cancel: Cancels any changes you have made.

 

© 2024 Altair Engineering Inc. All Rights Reserved.

Intellectual Property Rights Notice | Technical Support