跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
设计与 UI

workflow-creation

Programmatic workflow creation via API/MCP - build complete workflows without the UI editor

Happy Technologies LLC · 已有静态检查记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add Happy-Technologies-LLC/happy-platform-skills --skill workflow-creation

技能说明


name: workflow-creation version: 1.0.1 description: Programmatic workflow creation via API/MCP - build complete workflows without the UI editor author: Happy Technologies LLC tags: [admin, workflow, automation, approval, scripting, advanced] platforms: [claude-code, claude-desktop, chatgpt, cursor, any] tools: mcp: - SN-Create-Workflow - SN-Create-Activity - SN-Create-Transition - SN-Publish-Workflow - SN-Create-Record - SN-Update-Record - SN-Query-Table - SN-Execute-Background-Script rest: - /api/now/table/wf_workflow - /api/now/table/wf_workflow_version - /api/now/table/wf_activity - /api/now/table/wf_transition - /api/now/table/wf_condition - /api/now/table/wf_element_definition native: - Bash - Read complexity: advanced estimated_time: 30-90 minutes

Programmatic Workflow Creation

Overview

This skill enables you to create complete ServiceNow workflows entirely via API/MCP without using the visual Workflow Editor. This is essential for:

  • Automation pipelines - Create workflows as part of CI/CD deployments
  • Templated solutions - Generate standardized workflows from templates
  • Mass creation - Build multiple similar workflows programmatically
  • Version control - Store workflow definitions as code in Git
  • Environment migration - Recreate workflows across instances

Key Discovery: Activities store their logic in the input field as JavaScript code. This enables full programmatic workflow creation by:

  1. Creating the workflow structure (wf_workflow, wf_workflow_version)
  2. Creating activities with embedded scripts (wf_activity)
  3. Linking activities with transitions (wf_transition, wf_condition)
  4. Publishing the workflow version

Prerequisites

  • Roles: admin or workflow_admin
  • Permissions: Write access to workflow tables (wf_*)
  • Knowledge: Basic understanding of workflow concepts
  • Environment: Development or test instance (never create workflows in production first)
  • Related Skills: admin/update-set-management - Capture workflows in update sets

Table Architecture

Understanding the workflow tables is critical for programmatic creation.

Core Tables

wf_workflow (base definition)
    |
    +-- wf_workflow_version (published versions)
            |
            +-- wf_activity (activities with scripts)
            |       |
            |       +-- wf_element_definition (activity types)
            |       +-- wf_stage (optional stages)
            |
            +-- wf_transition (connects activities)
            |       |
            |       +-- wf_condition (transition logic)
            |
            +-- wf_condition (workflow-level conditions)

Key Relationships

TablePurposeKey Fields
wf_workflowBase workflow definitionname, table, description
wf_workflow_versionVersioned workflowworkflow, table, start, published
wf_activityIndividual activitiesworkflow_version, input, x, y
wf_transitionActivity connectionsfrom, to, condition
wf_conditionTransition conditionsactivity, condition, else_flag
wf_element_definitionActivity type definitionsname, default_input

Procedure

Step 1: Discover Activity Types

First, identify available activity types (wf_element_definition).

Using MCP:

Tool: SN-Query-Table
Parameters:
  table_name: wf_element_definition
  query: active=true
  fields: sys_id,name,category,description
  limit: 50

Common Activity Types:

sys_idNameUse Case
0a6c97790a0a0b2756919eb960284334NotificationSend email/SMS
1ca8d7cf0a0a0b265e9a000c2c08248cSet ValuesSet field values
35433da80a0a029a0028c639a1e51eb4Approval - UserUser approval
354e911f0a0a029a00e6a0e6ad74206fApproval - GroupGroup approval
283e8bb80a2581021d036a052ffc3433Approval CoordinatorMulti-approval container
38891b6f0a0a0b1e00efdfdd77602027Catalog TaskCreate catalog task
3961a1da0a0a0b5c00ecd84822f70d85TimerWait/delay
396807940a0a0b5c00afd9f67d9fd7a2Log MessageDebug logging
5994b389c0a80011000e64de81b1864cSubflowCall another workflow
7c9a2ba9c0a801650021ada408de0ebdJoinWait for multiple paths
7a8ea386c0a80066179bc1f5186e1d2bRollbackGo back to earlier activity

Note: Custom script activities can omit activity_definition entirely.

Step 2: Create Base Workflow

Create the workflow container record.

Using MCP (Preferred):

Tool: SN-Create-Workflow
Parameters:
  name: "P1 Incident Auto-Assignment"
  table: "incident"
  description: "Auto-assign P1 incidents to on-call engineer"
  condition: "priority=1^state=1"

Using SN-Create-Record:

Tool: SN-Create-Record
Parameters:
  table_name: wf_workflow
  data:
    name: "P1 Incident Auto-Assignment"
    description: "Auto-assign P1 incidents to on-call engineer"
    template: false
    access: "public"

Important: The name and table fields become read-only after creation. Choose carefully.

Save the sys_id: workflow_sys_id

Step 3: Create Workflow Version

Create a version that holds the actual workflow logic.

Using MCP:

Tool: SN-Create-Record
Parameters:
  table_name: wf_workflow_version
  data:
    name: "P1 Incident Auto-Assignment"
    workflow: [workflow_sys_id]
    table: "incident"
    condition: "priority=1^state=1"
    active: true
    published: false
    order: 100
    run_multiple: false
    after_business_rules: true

Key Fields:

FieldPurposeNotes
tableTarget tableREQUIRED - what records trigger this
conditionTrigger conditionEncoded query format
activeIs activeSet true for workflow to run
publishedIs publishedSet false initially, publish after testing
run_multiple
阅读完整来源 ↗