As part of creating or modifying a discovery pattern, modify existing custom operations that come as part of the base system or add new ones.

Before you begin

Role required: pd_admin

Practical knowledge of Java scripting is required.

About this task

For standard pattern operations, you can define only input parameters. However, there are custom operations for which you can define the business logic and the mechanism of the operation itself in addition to input parameters. For example, you can make a parameter mandatory or define which input parameters to use.

The following custom operations are available:
Cloud REST Call
Extracts information from configuration items of the PaaS (Platform-as-a-Service) type, such as Microsoft Azure or Amazon Web Services. This Java-based custom operation is part of the base system.
HTTP Get Call
Extracts information from configuration items (CIs), which use the HTTP protocol. This custom operation is part of the base system.
Cloud REST Query
Extracts information from configuration items of the PaaS (Platform-as-a-Service) type, such as Microsoft Azure or Amazon Web Services. This Java-script based custom operation is available only after downloading patterns version 1.0.24 or later from ServiceNow Store. Use this operation instead of the Cloud REST Call operation.

In addition to these custom operations, you can create your own operations to serve the needs of your discovery process. Custom operations created by you appear in the list of operations along with operations, which are part of the base system.

Procedure

  1. Navigate to All > Pattern Designer > Custom Operations.
  2. To add a custom operation, click New.
    Or
  3. To modify an existing custom operation, click its name in the table.
  4. For the new custom operation, enter a name describing the new operation in the Name field.
    For example, if the purpose of this operation is to extract information using a certain protocol, you can name it NetApp protocol query.
  5. Enter or modify the operation purpose or description in the Description field.
  6. Write the Java script in the Script pane to define the business logic of the operation.
    The script must comply to the following guidelines:
    • Create variables for operation parameters using the dollar sign in front of the variable name, for example, $fileName.
    • CTX is an object containing all the information which resulted from a pattern execution.
    • Use rtrn to indicate the string, which is the result of your custom operation.
    For example:
    ms.info('message from Custom operation MIDLogWrite ' + $logMessage);

    Where ms.info is the MID Server log. The $logMessage variable refers to the message that is created inside this MID Server log.

  7. In the Custom Operation Parameters related list, define the input parameters you used in the Java script.

    For example, if you used a variable for the log message file in the Java script, you must also define the parameter for this variable:


    Define parameters for variables used in the script.