npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

servicenow-utils

v0.0.1

Published

A CLI toolkit for common ServiceNow admin and developer operations using OOTB REST APIs

Downloads

167

Readme

🛠️ ServiceNow-Utils

✨ A CLI toolkit for common ServiceNow admin and developer operations using OOTB REST APIs. No extra plugins or scoped apps required! ✨

Node.js License

📂 File Structure

servicenow-utils/
├── bin/
│   └── cli.js                     ← npx entry point
├── src/
│   ├── commands/
│   │   ├── code-search.js
│   │   ├── legacy-wf-search.js    ← renamed from wf-search
│   │   ├── bulk-update.js
│   │   ├── export-legacy-wf-xml.js
│   │   └── reset-password.js
│   ├── lib/
│   │   ├── client.js              ← shared HTTP client with retry/backoff
│   │   └── env.js                 ← cwd-based env loader
│   └── index.js                   ← programmatic API exports
├── .github/workflows/
│   ├── npm-publish.yml            ← publishes to npmjs on release
│   └── github-publish.yml        ← publishes to GitHub Packages on release
├── .env.servicenow.example
├── .gitignore
├── package.json
└── README.md

📦 Installation

# Run directly with npx (no install needed)
npx servicenow-utils <command>

# Or install globally
npm install -g servicenow-utils

🔐 Authentication

Create a .env.servicenow file in your working directory:

cp .env.servicenow.example .env.servicenow
SN_INSTANCE=your-instance-name
SN_USERNAME=your-username
SN_PASSWORD=your-password

Alternatively, set SN_INSTANCE, SN_USERNAME, and SN_PASSWORD as environment variables directly.


🚀 Commands

🔍 code-search

Search for a keyword across all scripts and code in your ServiceNow instance using the OOTB Code Search API.

npx servicenow-utils code-search <keyword>

💡 Example:

npx servicenow-utils code-search GlideRecord

🕵️ legacy-wf-search

Search for a keyword inside legacy workflow (wf_workflow) activities. Useful for auditing or finding workflows that reference specific values.

npx servicenow-utils legacy-wf-search <keyword>

💡 Example:

npx servicenow-utils legacy-wf-search approval

🔄 bulk-update

Fetch records matching an encoded query and PATCH all of them with a given payload.

npx servicenow-utils bulk-update \
  --table <table> \
  --query <encoded_query> \
  --payload '<json>' \
  [--limit <number>] \
  [--dry-run]

| 🚩 Flag | ⚠️ Required | 📝 Description | |------|----------|-------------| | -t, --table | ✅ | Table name (e.g. incident) | | -q, --query | ✅ | Encoded query to filter records | | -p, --payload | ✅ | JSON string of fields to update | | -l, --limit | ❌ | Max records to update (default: 100) |

💡 Example:

npx servicenow-utils bulk-update \
  --table incident \
  --query "active=true^category=software" \
  --payload '{"assigned_to":"abc123","state":"2"}' \
  --limit 50

📤 export-legacy-wf-xml

Export the published legacy workflow XML for one or more catalog items. Files are saved locally as sr<n>-<catalog>-<workflow>.xml.

npx servicenow-utils export-legacy-wf-xml \
  --sys-id "<sys_id>" \
  [--sys-id "<another_sys_id>"] \
  [--out-dir <path>]

| 🚩 Flag | ⚠️ Required | 📝 Description | |------|----------|-------------| | -s, --sys-id | ✅ | Catalog item sys_id(s) to export (repeatable) | | -o, --out-dir | ❌ | Directory to save XML files (default: cwd) |

💡 Example:

npx servicenow-utils export-legacy-wf-xml \
  --sys-id "a1b2c3d4e5f6..." \
  --sys-id "f6e5d4c3b2a1..." \
  --out-dir ./exports

💻 Programmatic Usage

All commands are also available as importable functions:

import {
  codeSearch,
  legacyWFSearch,
  bulkUpdate,
  exportWFXml,
  loadEnv,
  createClient,
} from 'servicenow-utils';

// Load credentials first
loadEnv();

// Then call any function
const results = await codeSearch('GlideRecord');
const workflows = await legacyWFSearch('approval');

🌐 Publishing

Both GitHub Actions workflows trigger automatically on a published GitHub Release, and can also be run manually via workflow_dispatch.

| ⚙️ Workflow | 📦 Registry | 🏷️ Package name | |----------|----------|--------------| | npm-publish.yml | npmjs.com | servicenow-utils | | github-publish.yml | GitHub Packages | @<owner>/servicenow-utils |

For npm publishing, add your NPM_TOKEN as a repository secret. GitHub Packages uses the built-in GITHUB_TOKEN automatically.


✅ Requirements

  • 🟢 Node.js >= 22
  • ☁️ ServiceNow instance with REST API access
  • 🔑 User with sufficient permissions for the operations you intend to run

📜 License

See LICENSE for details.