Managing a script snippet library

The following topics help you understand the tasks that are related to managing a script snippet library:

Creating a code snippet in the library

When you create a code snippet, you must ensure that the snippet name adheres to the following standards:

  • The code snippets that are created for the same vendor must have unique snippet names.
  • The snippet name can be alphanumeric.
  • The snippet name can include spaces.
  • The snippet name must not include any special characters.
  • As a best practice, you can provide the snippet name in title case, that is, you must capitalize the first letter of each word.

You can use the following steps to create a new code snippet in IBM Task Mining:

  1. On the Script Snippet library page, click Add new snippet.

    Add snippet

  2. In the Create a new script snippet dialog box, do the following steps:

    a. In the Vendor box, select the vendor.
    b. In the Name box, type a name for the code snippet that adheres to the naming standards.
    c. Optional: In the Description box, type a description for the code snippet.
    d. Do one of the following steps:

    • To assign an existing application to the snippet, do the following steps:

      i. Click Select existing applications to select an application from the existing list.
      ii. In the Existing application list, select the required application.

    • To add a new application to the snippet, do the following steps:

      i. Click Create new applications to create a new application for the snippet.
      ii. In the Name box, type an application name, and then click Add application.

    e. Set Select existing applications.
    f. In the Script box, type or paste the script.
    g. Click Save.

    Define snippet


    NOTE: The code snippets are created based on the vendor application. You can copy the code from the generated bot, for example, an existing IBM RPA bot, and paste the code in the Script box. For more information on generating an RPA bot, see Generating an RPA bot.


  3. The message, Snippet has been successfully created appears and indicates that the code snippet is created. The created code snippet is available in the view.

    Snippet created

Viewing the details of a code snippet

You can use the following step to view the contents of a code snippet:

  • On the Script Snippet library page, expand the required code snippet.

    Expand snippet


NOTE: You can use the following steps to filter a code snippet by name and by vendor:

  • To filter the code snippets of a vendor, in the All box, select the required vendor.
  • To filter the code snippets based on the application, in the Application box, select the required application.
  • To search for a code snippet by name, in the what are you looking for today? box, type the name of the code snippet. The view displays the code snippet. Note that the search is not case-sensitive.

Editing, deleting, and duplicating a code snippet

Edit a code snippet

You can use the following steps to edit a code snippet:

  1. On the Script Snippet library page, click the open and close list of options button corresponding to the required code snippet, and then click Edit.

    Edit snippet

  2. In the Edit script snippet dialog box, update the required details, and then click Save.

    Update snippet


NOTES:

  • You can edit a code snippet only if you are the owner of the script or if your user credentials have the edit permission. For all other instances, the Edit feature is disabled.

  • The Edit script snippet dialog box displays the following warning message if the selected snippet is assigned to more than one task:

    Warning Editing this script will impact the n linked tasks associated to this snippet

  • To add applications to a snippet or to delete an application from the snippet, you must use the Edit script snippet dialog box.


Duplicate a code snippet

You can use the following step to duplicate a code snippet:

  • On the Script Snippet library page, click the open and close list of options button corresponding to the required code snippet, and then click Duplicate.

    Duplicate snippet

The message Snippet has been successfully duplicated appears and the duplicated snippet appears in the view. The name of the duplicated snippet includes the date and timestamp when it is created.

Delete a code snippet

You can use the following steps to delete a code snippet:

  1. On the Script Snippet library page, click the open and close list of options button corresponding to the required code snippet, and then click Delete.

    Delete snippet

  2. In the Confirm Deletion message box, click Delete.

    Delete snippet2


NOTE: You can delete a code snippet only if you are the owner of the snippet.


Importing and exporting code snippets

In IBM Task Mining, you can import to a snippet library and export from a snippet library.

Exporting from the snippet library

You can choose to export from the snippet library corresponding to one or more vendors.

You can use the following steps to export code snippets from the snippet library:

  1. On the Script Snippet Library page, click Export snippets.

    Export Snippet library

  2. In the Export script snippets dialog box, do the following steps: a. In the Select vendors you wish to export section, select the required vendors. b. In the Included applications section, click the application tags to select the required application names.
    c. Click Export selection.

    Export selection

  3. The exported code snippet is available in the downloads folder of your device. Note that the file format of the exported code snippet is .json file.


NOTES:

  • By default, all the application names are selected in the Export script snippets dialog box. You can click each tag to deselect the application names that are not required.

  • The Included applications section is displayed only after you select the vendor.


Importing snippets into the snippet library

When you import code snippets into the snippet library, you must ensure that the code snippets adhere to the following standards and formats that are defined in the snippet library:

  • The file format of the code snippet must be .json.

  • The data in the .json file must be represented by using the same fields as in the IBM Task Mining Snippet Library. In other words, the .json file should have the following fields:

    • snippetName
    • snippet
    • vendor
    • snippetType
    • description
  • The value in the snippetName field must adhere to the naming rules in IBM Task Mining. For more information on naming rules, see Create a new code snippet in the library.

  • The value in the snippetType field must be TASK.

  • The value in the vendor field must include the name of the vendor that IBM Task Mining supports. After importing the file, the snippet is linked to the vendor based on the name defined in the vendor field.

You can use the following steps to import a code snippet:

  1. On the Script Snippet Library page, click Import snippets.

    Import Snippet library

  2. In the Choose Files to Upload dialog box, select the required .json file, and then click Upload.

  3. The imported snippet library is available in the view.

Error messages that are displayed during importing a snippet

IBM Task Mining displays an error message for the following scenarios:

  • The content of the imported file does not adhere to the snippet library standards.


    Example: Assume that the code snippet is a .json file with the following contents:

    [ {
    "snippetName" : "Initial Task",
    "snippet" : "//defVar --name customerId --type Numeric\n\twebClose --name web01 --leavebrowseropen",
    "vendor" : "IBM_RPA",
    "snippetType" : "TASK",
    "description" : "GitHub Click"
    }, {
    "snippetName" : "GitHub !87",
    "snippet" : "//defVar --name customerId --type Numeric\n\twebClose --name web01 --leavebrowseropen",
    "vendor" : "IBM_RPA",
    "snippetType" : "TASK",
    "description" : null
    }, {
    "snippetName" : "GitHub Comment 165",
    "snippet" : "//defVar --name customerId --type Numeric\n\twebClose --name web01 --leavebrowseropen",
    "vendor" : "XYZ",
    "snippetType" : "TASK",
    "description" : null
    }, {
    "snippetName" : "Provauno",
    "snippet" : "//defVar --name customerId --type Numeric\n\twebClose --name web01 --leavebrowseropen",
    "vendor" : "IBM_RPA",
    "snippetType" : "PROCESS",
    "description" : null
    } ]
    

    In this example, only the Initial Task snippet adheres to the Snippet Library standards. Hence, when you try to import the code snippet, the application displays the error message, Invalid File Format - Snippet name should contain alphanumeric and whitespace chars.


  • If the name and vendor details of the imported code snippet is identical to an existing snippet.

    IBM Task Mining displays the error message, Duplicate snippets found, when you try to import a duplicate code snippet with identical snippet name and vendor details. The application also displays the Duplicate snippets found message box.

    In the Duplicate snippets found message box, click any one of the following options, and then click Proceed to complete the import process:

    • Replace existing with new imports
      This option replaces the existing code snippet with the imported code snippet.

    • Keep existing and do nothing
      This option retains the exiting code snippet and skips the duplicate snippet during the import process.

    • Keep both
      This option allows you to maintain the existing code snippet and the duplicate code snippet in the snippet library. Additionally, the snippet name of the imported code snippet is appended with a timestamp to differentiate it from the existing code snippet.