Skip to content

Transform Map: send rows through the IRE with serial number cleansing - #2675

Open
itam-automation wants to merge 2 commits into
ServiceNowDevProgram:mainfrom
itam-automation:feature/ire-onbefore-serial-cleansing
Open

itam-automation wants to merge 2 commits into
ServiceNowDevProgram:mainfrom
itam-automation:feature/ire-onbefore-serial-cleansing

Conversation

@itam-automation

@itam-automation itam-automation commented Nov 11, 2026 •

Copy link
Copy Markdown

PR Description:

An onBefore transform script that sends each import row through the IRE (sn_cmdb.IdentificationEngine.createOrUpdateCI) instead of letting the transform map write into the CMDB, plus a small Script Include that drops placeholder serial numbers before identification.

The placeholder part is the reason for this snippet: on a PDI with the out-of-box hardware rule, a second computer with a different name, no MAC address and the serial "To be filled by O.E.M." was identified as the existing CI. The cleanser uses the same check as Discovery (SerialNumberManager.isValid(), rules in dscy_invalid_serial), so the list is maintained in one place. The outcome of each row (operation, sys_id, IRE errors) is written to the import row comment. Rows with an IRE error are skipped and logged, so one bad row does not stop the import.

Tested on a PDI (Brazil), including a transform run with an error row in the middle of the import set. Results are in the README. Existing IRE snippets in the repo show the createOrUpdateCI call on its own. This one covers the transform map use case and the serial number problem.

Pull Request Checklist

Overview

  • I have read and understood the CONTRIBUTING.md guidelines
  • My pull request has a descriptive title that accurately reflects the changes and the description has been filled in above.
  • I've included only files relevant to the changes described in the PR title and description
  • I've created a new branch in my forked repository for this contribution

Code Quality

  • My code is relevant to ServiceNow developers
  • My code snippets expand meaningfully on official ServiceNow documentation (if applicable)
  • I've disclosed use of ES2021 features (if applicable)
  • I've tested my code snippets in a ServiceNow environment (where possible)

Repository Structure Compliance

  • I've placed my code snippet(s) in one of the required top-level categories
  • I've used appropriate sub-categories within the top-level categories
  • Each code snippet has its own folder with a descriptive name

Documentation

  • I've included a README.md file for each code snippet
  • The README.md includes description, usage, prerequisites

Restrictions

  • My PR does not include XML exports of ServiceNow records
  • My PR does not contain sensitive information (passwords, API keys, tokens)
  • My PR does not include changes that fall outside the described scope

In an onBefore script, error = true halts the transformation of the
whole import set, so one row without identifying attributes stopped
all rows after it. The script now sets ignore = true first, writes IRE
errors to the row comment and the import log, and catches script
errors. Column names for the serial number and the source key are
constants now.

README: result of a transform run with an error row in the middle,
the placeholder case narrowed to what was tested, and the fallback of
the serial number check.
@itam-automation

Copy link
Copy Markdown
Author

Fixed the error handling in 3389a0e. The script set error = true for rows with an IRE error. In an onBefore script that halts the transformation of the whole import set, so one row without identifying attributes stopped every row after it. It now sets ignore = true first, writes IRE errors to the row comment and the import log, and catches script errors as well.

I tested it again as a real transform run on a PDI, with the bad row in the middle of the import set. With the old version the third row stayed Pending, with the new one it was inserted. The README has the details.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant