Creating and editing scripts

You have several options for creating scripts:

  • Script Editor type script syntax in the Script Editor window
  • Command log copy script syntax from the command log
  • Script Recorder record the syntax for commands as you execute them
  • Syntax capture insert the syntax for commands as you select them in the user interface without executing them
  • Table history copy script syntax from the history of an output table

You can use these options in combination. For example, you could begin a script by copying syntax from the command log, and then add additional lines of syntax directly in the Script Editor window.

To edit an existing script in Analytics, you must use the Script Editor.

You also have the option of using a text editor of your choice, and copying and pasting syntax into an Analytics script.

Code completion

As you type script syntax in the Script Editor, Analytics performs different types of code completion. Code completion reduces the labor associated with typing syntax, and also presents the valid form of ACLScript commands, functions, keywords, and parameters.

  • Auto-completion of commands, functions, and keywords As you begin to type, the auto-completion feature offers a progressively updated pick list of ACLScript commands, functions, and keywords that match the typed characters. You can select an item from the list to automatically complete the syntax item.

  • Pop-up help for function parameters When you type the opening parenthesis after a valid function name, pop-up help displays the data type of the output returned by the function, and the required format for the function parameters.

  • Auto-close of paired syntax items When you type the opening character of any of the paired syntax items below, the closing character is automatically supplied:

    • Double quotation marks ""

    • Single quotation marks ''

    • Back quotation marks ``

    • Parentheses ()

You can turn off auto-completion of commands, functions, and keywords by selecting Disable auto complete in scripts in the Interface tab in the Options dialog box (Tools > Options).

Pop-up help for function parameters, and auto-close of common syntax items, cannot be disabled.

Create or edit a script in the Script Editor

Create or edit scripts by typing the required ACLScript syntax directly into the Script Editor, or by using one of the other supported methods for entering syntax.

Note

When you create or edit a script you must ensure that each ACLScript command is entered on a separate line.

Create a script from the command log

You can copy log entries from the Log tab in the Navigator as the starting point for creating a new script, or to add to an existing script. The syntax of each command previously executed in Analytics is recorded in an individual log entry.

You can select the following types of log entries and copy them to a new or existing script:

  • individual entries
  • a series of entries associated with a table
  • larger groups of entries associated with a session or a time period

Create a script with the Script Recorder

The AnalyticsScript Recorder allows you to create a script by recording your actions as you work with tables and commands in the Analytics user interface. The advantage of using the Script Recorder to create scripts is that you do not need to manually enter the required syntax for each ACLScript command, or even know the syntax.

Only commands are captured by the Script Recorder. As a general rule, if the command appears in the command log, it can be captured by the Script Recorder.

Tip

The Script Recorder is also a useful tool for learning ACLScript. You can record a series of analysis steps using the Script Recorder and then view the resulting script to see the series of commands and syntax required to reproduce the behavior in a script.

Create a script with syntax capture

Syntax capture allows you to use Analytics menus and dialog boxes to automatically insert ACLScript syntax into a script.

Create a script from table history

You can create a script based on the history associated with an Analytics output or results table.

For example, if you add a monthly inventory table to an Analytics project and extract relevant divisions and items to a new table, you could script this process based on the table history associated with the first output table you created.

Each table created as the output of an Analytics command keeps a record of the commands used to create the table, including commands that create any intermediate tables between the original Analytics table and the output table. You can copy this table history to a new script that you can then use to automate creation of subsequent output tables.

Acquire a Diligent One access token

Caution

The generated access token matches the account used to sign in to Diligent One. As a scriptwriter, specifying your own access token in a script may not be appropriate if the script will be used by other people.

Safeguard access tokens like any account password.

Use an existing access token unless you have a reason for creating a new one. If the existing token does not work, create a new one. Using an existing token cuts down on the number of tokens you need to manage.

  1. Do one of the following:

    • From the Analytics main menu, select Tools > Diligent One Access Token.

    • In the Script Editor, right-click and select Insert > Diligent One Token.

    The Manage API tokens page opens in your browser. You may be required to first sign in to Diligent One.

    Access to the Manage API tokens page through Analytics is a convenience feature. You can also sign in to Diligent One and access the page through your user profile without using Analytics.

  2. Do one of the following:

    • Use an existing token

      1. In the Token column, click the partially masked token that you want to use.

      2. Enter your Diligent One account password and click Confirm.

        The unmasked token is displayed.

      3. Click Copy to copy the token.

        Tip

        Do not close the dialog box containing the token until you have successfully pasted the token.

    • Create a new token

      1. Click Add token > Analytics.

      2. In the New Analytics token side panel, specify the following information:

        Field or option Description
        Description

        Enter a description that provides useful information, such as:

        • The purpose of the token
        • Where the token is used – for example, the name and location of the Analytics script, or the name and location of the robot task
        Token expiry
        • Enabled the token expires after the number of days that you specify
        • Disabled the token never expires

        Note

        Your organization may have a security policy that requires tokens to expire after a certain amount of time. Creating tokens with an expiry is a good practice. Diligent One sends you an automated email notification in advance of the expiry date.

        Expires in Specify the number of days before the token expires (1 to 365).
        Password Enter your Diligent One account password.
      3. Click Generate token.

      4. Click Copy to copy the token.

        Tip

        Do not close the side panel containing the token until you have successfully pasted the token.

  3. Depending on which password definition method you are using, do one of the following:

    • PASSWORD analytic tag In the Task Designer in an ACL robot, paste the copied token into a password parameter field.

    • PASSWORD command In Analytics, paste the copied token into a password prompt that appears during script execution.

    • SET PASSWORD command In Analytics, paste the copied token at the appropriate point in the SET PASSWORD command syntax in a script.

  4. In Launchpad, close the dialog box or the side panel containing the token.

    If you created a new token, a partially masked version of the token is added to the top of your list of tokens.

    For more information, see Creating and managing Diligent One access tokens.