Thank you for your feedback.
Form temporarily unavailable. Please try again or contact docfeedback@servicenow.com to submit your comments.
Versions
  • London
  • Kingston
  • Jakarta
  • Istanbul
  • Helsinki
  • Geneva
  • Store
Close

Customize parsing strategies

Customize parsing strategies

You can modify parsing strategies that come as part of the base system or add new ones. Parsing strategies are part of discovery patterns, which Service Mapping and Discovery use to discover and map configuration items (CIs).

Before you begin

Practical knowledge of Java scripting is required.

Role required: pd_admin

About this task

Parsing serves to analyze syntax of the source file. You extract values from parsed files, which allows you to convert these values into variables. There are standard parsing strategies, which are part of the base system. If you cannot extract data using the standard parsing strategies, you can create your own parsing strategy. Custom parsing strategies are JavaScript files.

The JavaScript for parsing strategy must comply to the following guidelines:
  • You may use the content variable to refer to the raw data resulting from executing the operation.
  • Use rtrn to indicate the string, which is the result of your custom parsing.
  • The script output must be in well-formed XML syntax.

    For example, the output must contain correct tags and markup:

    <root>
    <OS>Windows</OS>
    <version>10</version>
    </root> 
  • If necessary, you may use third-party JavaScripts to convert the content into XML.

    For example, to convert the content from JSON into XML, use the X2JS JavaScript provided by open-source software.

    var xtojs = new X2JS();
    var result = xtojs.js2xml(jsonObj);
    var finalResult = "<root>" + result + "</root>";

Procedure

  1. Navigate to Pattern Designer > Custom Parsing Strategies.
  2. To modify the JSON custom parsing strategy, select JSON file.
    Alternatively, click New to create a new JSON file.
  3. For the new custom parsing strategy, enter a name describing the new strategy in the Name field.
    For example, if the purpose of this strategy is to extract information using a certain protocol, use this protocol as the name.
  4. Enter or modify the parsing strategy purpose in the Description field.
  5. Write the JavaScript in the Script pane to define the business logic of parsing.
  6. Click Update or Submit.

What to do next

Use this custom parsing strategy for defining operations inside pattern steps.

This site is scheduled for a small content update on Tuesday, December 18th, between the hours of 4:00pm and 8:00pm Pacific Time (Dec 19 00:00 – Dec 19 4:00 UTC). Access to this site may be slightly delayed during that time.