On classification script objects for Discovery

  • Release version: Zurich
  • Updated March 26, 2026
  • 2 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of On classification script objects for Discovery

    The On classification script in a process classifier allows ServiceNow customers to customize application records during Discovery. By default, application names follow the format@. This script enables renaming and tailoring the application name to better match business requirements, improving clarity and management of discovered applications.

    Show full answer Show less

    Key Features

    • Customizing application names: Modify the default naming convention by using the On classification script field to append suffixes or include process parameters, such as command line arguments, to uniquely identify application instances.
    • Passing parameters to probes: Use the gprobeparameters object within the script to pass name/value pairs to triggered probes, allowing more dynamic and context-aware Discovery processes.
    • Access to script objects: The script has access to several objects for flexible customization:
      • current: A JavaScript object to update application record properties.
      • gsensor: Contains the device record (computer CI) information.
      • gclassification: Provides access to the process classifier and its properties such as name, command, parameters, and PID.
      • name, command, parameters: Variables representing the process details.
      • gprobeparameters: Used to define parameters passed to probes during classification.

    Practical Use

    ServiceNow customers can leverage the On classification script to:

    • Rename application records to include meaningful identifiers like process parameters or custom suffixes, aiding in easier identification and reporting.
    • Pass process-specific parameters to subsequent probes dynamically, enhancing the accuracy and depth of Discovery data.
    • Adapt Discovery behavior to complex environments where default naming conventions are insufficient.

    This customization is implemented within the process classifier record's On classification script field and integrates seamlessly with the Application Dependency Mapping sensor.

    Use an On classification script in a process classifier to customize an application record.

    Renaming the default application name

    By default, application names are in this format: <name of the process classifier>@<the name of the computer CI where the process resides>;

    For example, for a MySQL server running on a computer called machineA, the application is named mysql@machineA.

    You can use the On classification script field in the process classifier record to change the default application name to match your business needs. For example, the following script changes the default application name to include a suffix after the process classifier:

    var computerName = g_sensor.deviceGR.name;
    var processClassifierName = g_classification.name;
    current.name = processClassifierName + "999" + "@" + computerName;
    In this example, the name of the application record becomes mysql999@machineA.
    Another common technique is to set the application name based on the name, command, and parameter variables. For example, an Eclipse process might have the following values in these variables:
    name "eclipse"
    command "/glide/eclipse/Eclipse.app/Contents/MacOS/eclipse"
    parameter "-psn_0_1884620"
    If an Eclipse application runs on a computer called machineA, ServiceNow names the application eclipse@machineA. The following script appends the parameter value as part of the application name.
    var computerName = g_sensor.deviceGR.name;
    var processClassifierName = g_classification.name;
    current.name = processClassifierName + parameters + "@" + computerName;
    In this example, the name of the application record becomes eclipse-psn_0_1884620@machineA.
    Sometimes it is useful to pass values to the triggered probes in the process classification. You can do this by creating a custom script that defines a name/value pair for the g_probe_parameters object. For example:
    g_probe_parameters['processCommand'] = command;

    In this example, when a classification record triggers a probe, the script passes the probe a parameter called processCommand with the value of the command variable.

    Script objects

    Use these objects in the script:
    Script object Description
    current Points to a JavaScript object with its [property:value] pair to update the application record. It is not an actual GlideRecord object of the application.
    g_sensor Points to the DiscoverySensor object defined in the DiscoverySensor script include. This object contains a deviceGR object, which points to the computer CI record on which the process resides.
    g_classification Points to the process classifier record. This object is set in the Application Dependency Mapping sensor and is available in the On Classification script field. Use it to access the classified process properties: name, command, parameters, PID, and table name.
    name Points to the process name.
    command Points to the process command.
    parameters Points to the process parameters.
    g_probe_parameters A JavaScript object that enables parameter passing to the triggered probes.