How to map fields from Qualys to SNOW table

Shrutij11
Tera Contributor

We have Qualys Integration done in our environment the requirement is to add new fields from qualys to SNOW table. I can see the field in XML response. I tried modifying this script - QualysHostImportReportProcessor with the below code.

 if (!gs.nil(host["TRURISK_SCORE"]))
            host["u_trurisk_score"] = host["TRURISK_SCORE"];
but this is not working. Can anyone suggest solution for this and also share debugging methods.
1 REPLY 1

Chetna_dev
Kilo Sage

To add new fields from the Qualys XML response to the ServiceNow table, you can try the following approach to resolve the issue and debug the integration:

Steps to Solve:

  1. Ensure the Field Exists in the Target Table:

    • Confirm that the field u_trurisk_score exists in the target table (e.g., cmdb_ci_computer or another table where the Qualys data is being imported).
    • If it does not exist, create a new custom field u_trurisk_score of the appropriate data type (e.g., integer, string, etc.).
  2. Modify the Script for Field Mapping: When parsing the XML response, ensure the script captures the correct value from the XML and assigns it to the appropriate ServiceNow field.

    Example script modification:

     
    if (!gs.nil(host["TRURISK_SCORE"])) { host.u_trurisk_score = host["TRURISK_SCORE"]; }

    Note the change: the u_trurisk_score is being directly set on host, not as a string in brackets.

  3. Debugging Tips:

    • Check the XML Structure: Ensure the field name TRURISK_SCORE is correctly spelled and matches the field in the Qualys XML response.

    • Log the XML Response: Add logging to print the XML response and check if TRURISK_SCORE is being captured correctly:

      gs.info("TRURISK_SCORE Value: " + host["TRURISK_SCORE"]);

      This helps confirm if the value exists in the XML.

    • Use gs.debug for Detailed Logging: Enable debug logging in your script for detailed troubleshooting:

       
      gs.debug("Host TRURISK_SCORE: " + host["TRURISK_SCORE"]); gs.debug("Mapped u_trurisk_score: " + host.u_trurisk_score);
    • Enable Debugging: Go to System Diagnostics > Log > Debug Log to monitor real-time debug logs for your script execution.

  4. Check Script Execution Order: Ensure the QualysHostImportReportProcessor script is running after the XML response has been parsed and the host object is fully populated.

  5. Ensure Data Type Compatibility: If the TRURISK_SCORE is not a direct match for the u_trurisk_score field data type, use data conversion where necessary. For example:

     
    host.u_trurisk_score = parseInt(host["TRURISK_SCORE"], 10);

Recap of Debugging Methods:

  • Use gs.info() or gs.debug() to log important data.
  • Check the debug logs in System Logs > All or use Debug Log for real-time debugging.
  • Verify field names, data types, and the structure of the XML response.

if you found this helpful please accept as solution and mark helpful

best

Chetna