mcpField
I
item-creation

item-creation

github.com/happy-technologies-llc开发4141 次安装2 天前更新
代码仓库

关于 item-creation

此技能面向 ServiceNow 服务目录管理员,指导创建和发布目录项目及其请求表单。它涵盖分类、表单变量、可复用变量集、定价和履行配置,并包括发布前验证。

主要功能

  1. 01创建目录项目并设置分类
  2. 02添加多种类型的表单变量
  3. 03配置可复用变量集和选项
  4. 04设置价格与履行流程
  5. 05发布并验证项目配置

适用场景

  1. 01创建新的员工服务目录项目
  2. 02构建包含选择项的申请表单
  3. 03在多个项目间复用常见字段
  4. 04配置请求项目的价格和处理流程

MCP 相关

该技能使用 ServiceNow MCP 工具查询和创建目录项目、分类及变量记录,并更新配置、激活项目和验证结果。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/happy-technologies-llc/happy-platform-skills --skill item-creation

安装后在 Claude Code 中输入/item-creation确认已加载。

详细介绍

服务目录条目创建

概述

本技能涵盖创建服务目录条目的完整流程:

  • 了解目录条目的结构
  • 为条目设置适当的分类
  • 添加类型正确的变量(表单字段)
  • 配置可复用的变量集
  • 设置定价和履行选项
  • 发布并测试条目

适用场景: 创建新的服务项目、构建请求表单或配置目录条目的履行流程时。

前提条件

  • 角色: catalog_admin 或 admin
  • 访问权限: sc_cat_item、item_option_new、sc_category 表
  • 知识: 服务目录结构、变量类型
  • 相关技能: 如需高级变量配置,请完成 catalog/variable-management

流程

步骤 1:了解目录条目结构
sc_catalog (Catalog)
└── sc_category (Category)
    └── sc_cat_item (Catalog Item)
        ├── item_option_new (Variables) - Form fields
        ├── io_set_item (Variable Set M2M) - Reusable variable groups
        ├── sc_cat_item_catalog (Catalog M2M) - Multi-catalog support
        └── workflow/flow (Fulfillment) - Processing logic

主要表:

表用途
sc_cat_item目录条目定义
sc_category用于分类的类别
item_option_new单个变量(表单字段)
io_set_item变量集与条目的映射
question_choice目录变量的选项(不是 sys_choice!)
步骤 2:查找或创建类别

查询现有类别:

Tool: SN-Query-Table
Parameters:
  table_name: sc_category
  query: active=true
  fields: sys_id,title,parent,sc_catalog,order
  limit: 100

如有需要,创建新类别:

Tool: SN-Create-Record
Parameters:
  table_name: sc_category
  data:
    title: "Employee Services"
    sc_catalog: [catalog_sys_id]  # Usually Service Catalog
    parent: [parent_category_sys_id]  # Optional
    description: "Services for employee onboarding and lifecycle"
    icon: "user"
    active: true
    order: 100
步骤 3:创建目录条目

基本目录条目:

Tool: SN-Create-Record
Parameters:
  table_name: sc_cat_item
  data:
    name: "New Employee Laptop Request"
    short_description: "Request a laptop for new employee"
    description: |
      Use this form to request a laptop for a new employee.

      Processing time: 3-5 business days

      Please have the following information ready:
      - Employee name and start date
      - Department and manager
      - Required software
    category: [category_sys_id]
    sc_catalogs: [catalog_sys_id]
    workflow: [workflow_sys_id]  # Or use flow_designer_flow
    active: true
    visible_standalone: true
    visible_bundle: true
    visible_guide: true
    order: 100
    meta: "laptop,computer,hardware,new hire"  # Search keywords

高级条目配置:

Tool: SN-Create-Record
Parameters:
  table_name: sc_cat_item
  data:
    name: "Software License Request"
    short_description: "Request software license"
    category: [category_sys_id]
    sc_catalogs: [catalog_sys_id]
    # Pricing
    price: 0
    recurring_price: 99.00
    recurring_frequency: "monthly"
    # Approval
    no_quantity: false
    no_proceed_checkout: false
    # Availability
    start_date: "2026-01-01"
    end_date: ""  # No end date
    availability: "on_desktop"  # desktop, mobile, both
    # SLA
    delivery_time: "3 00:00:00"  # 3 days in GlideDuration format
    # Template
    template: [template_sys_id]  # Pre-fill variables
    active: true
步骤 4:添加变量(表单字段)

变量类型参考:

类型值用例
单行文本16简短文本输入(姓名、标题)
多行文本6长文本(描述、备注)
选项(单选按钮)12–5 个选项,可同时查看
选择框(下拉菜单)56 个或更多选项,或标签较长
引用8链接到 ServiceNow 记录
是/否7布尔切换
复选框7与是/否相同
日期9日期选择器
日期/时间10日期和时间选择器
电子邮件32电子邮件验证
URL26URL 验证
数值刻度21–10 评分
查找选择框21筛选后的引用
容器开始19将变量以视觉方式分组
容器结束20结束容器组
标签11仅显示文本
分隔符12视觉分隔线
宏14执行 UI 宏
掩码25类似密码的输入
HTML17富文本/HTML 显示

创建单行文本变量:

Tool: SN-Create-Record
Parameters:
  table_name: item_option_new
  data:
    cat_item: [catalog_item_sys_id]
    name: "employee_name"
    question_text: "Employee Full Name"
    type: 16  # Single Line Text
    order: 100
    mandatory: true
    active: true
    help_text: "Enter the employee's full legal name"
    default_value: ""

创建选择框(下拉菜单)变量:

Tool: SN-Create-Record
Parameters:
  table_name: item_option_new
  data:
    cat_item: [catalog_item_sys_id]
    name: "laptop_type"
    question_text: "Laptop Type"
    type: 5  # Select Box
    order: 200
    mandatory: true
    active: true
    include_none: false

创建选项(单选按钮)变量:

Tool: SN-Create-Record
Parameters:
  table_name: item_option_new
  data:
    cat_item: [catalog_item_sys_id]
    name: "warranty"
    question_text: "Warranty Option"
    type: 1  # Choice (Radio)
    order: 300
    mandatory: true
    active: true

创建引用变量:

Tool: SN-Create-Record
Parameters:
  table_name: item_option_new
  data:
    cat_item: [catalog_item_sys_id]
    name: "manager"
    question_text: "Manager"
    type: 8  # Reference
    reference: sys_user
    reference_qual: "active=true^roles!=admin"  # Filter options
    order: 400
    mandatory: true
    active: true

创建日期变量:

Tool: SN-Create-Record
Parameters:
  table_name: item_option_new
  data:
    cat_item: [catalog_item_sys_id]
    name: "start_date"
    question_text: "Employee Start Date"
    type: 9  # Date
    order: 500
    mandatory: true
    active: true

创建多行文本变量:

Tool: SN-Create-Record
Parameters:
  table_name: item_option_new
  data:
    cat_item: [catalog_item_sys_id]
    name: "special_requirements"
    question_text: "Special Requirements or Notes"
    type: 6  # Multi-Line Text
    order: 600
    mandatory: false
    active: true
    default_value: ""
步骤 5:为变量添加选项

重要: 目录变量的选项使用 question_choice 表,而不是 sys_choice!

为选择框或选项变量添加选项:

Tool: SN-Create-Record
Parameters:
  table_name: question_choice
  data:
    question: [variable_sys_id]  # item_option_new sys_id
    text: "MacBook Pro 14-inch"
    value: "macbook_pro_14"
    order: 100
    inactive: false
Tool: SN-Create-Record
Parameters:
  table_name: question_choice
  data:
    question: [variable_sys_id]
    text: "MacBook Pro 16-inch"
    value: "macbook_pro_16"
    order: 200
    inactive: false
Tool: SN-Create-Record
Parameters:
  table_name: question_choice
  data:
    question: [variable_sys_id]
    text: "Dell XPS 15"
    value: "dell_xps_15"
    order: 300
    inactive: false
步骤 6:配置变量集(可复用的分组)

变量集可让多个目录条目复用常用的变量组。

查询现有变量集:

Tool: SN-Query-Table
Parameters:
  table_name: item_option_new_set
  query: active=true
  fields: sys_id,title,description
  limit: 50

创建新变量集:

Tool: SN-Create-Record
Parameters:
  table_name: item_option_new_set
  data:
    title: "Standard Location Questions"
    description: "Common location-related variables for hardware requests"
    active: true
    type: "one_to_one"  # or "one_to_many"
    order: 100

将变量添加到变量集:

Tool: SN-Create-Record
Parameters:
  table_name: item_option_new
  data:
    variable_set: [variable_set_sys_id]  # Instead of cat_item
    name: "delivery_location"
    question_text: "Delivery Location"
    type: 16
    order: 100
    mandatory: true
    active: true

将变量集关联到目录条目:

Tool: SN-Create-Record
Parameters:
  table_name: io_set_item
  data:
    sc_cat_item: [catalog_item_sys_id]
    variable_set: [variable_set_sys_id]
    order: 100
步骤 7:配置定价

一次性价格:

Tool: SN-Update-Record
Parameters:
  table_name: sc_cat_item
  sys_id: [catalog_item_sys_id]
  data:
    price: 1500.00
    cost: 1200.00  # Internal cost
    recurring_price: 0

周期性价格:

Tool: SN-Update-Record
Parameters:
  table_name: sc_cat_item
  sys_id: [catalog_item_sys_id]
  data:
    price: 0
    recurring_price: 49.99
    recurring_frequency: "monthly"  # monthly, quarterly, yearly

基于变量的定价: 根据所选选项,通过工作流或目录客户端脚本配置定价。

步骤 8:配置履行

分配履行组:

Tool: SN-Update-Record
Parameters:
  table_name: sc_cat_item
  sys_id: [catalog_item_sys_id]
  data:
    fulfillment_group: [group_sys_id]
    group: [group_sys_id]  # Alternative field

分配工作流:

Tool: SN-Update-Record
Parameters:
  table_name: sc_cat_item
  sys_id: [catalog_item_sys_id]
  data:
    workflow: [workflow_sys_id]

分配 Flow Designer 流程:

Tool: SN-Update-Record
Parameters:
  table_name: sc_cat_item
  sys_id: [catalog_item_sys_id]
  data:
    flow_designer_flow: [flow_sys_id]
步骤 9:发布并测试

激活目录条目:

Tool: SN-Update-Record
Parameters:
  table_name: sc_cat_item
  sys_id: [catalog_item_sys_id]
  data:
    active: true

验证条目配置:

Tool: SN-Query-Table
Parameters:
  table_name: sc_cat_item
  query: sys_id=[catalog_item_sys_id]
  fields: name,short_description,category,active,workflow,price

验证变量:

Tool: SN-Query-Table
Parameters:
  table_name: item_option_new
  query: cat_item=[catalog_item_sys_id]
  fields: name,question_text,type,order,mandatory,active
  limit: 50

验证变量选项:

Tool: SN-Query-Table
Parameters:
  table_name: question_choice
  query: question.cat_item=[catalog_item_sys_id]
  fields: question.name,text,value,order
  limit: 100

完整示例:新员工笔记本电脑请求

# 1. Create catalog item
Tool: SN-Create-Record
Parameters:
  table_name: sc_cat_item
  data:
    name: "New Employee Laptop Request"
    short_description: "Request a laptop for new employee"
    description: "Complete this form to request laptop provisioning for new hires"
    category: [category_sys_id]
    sc_catalogs: [catalog_sys_id]
    price: 0
    delivery_time: "5 00:00:00"
    active: true
# Result: sys_id = "abc123"

# 2. Create employee name variable
Tool: SN-Create-Record
Parameters:
  table_name: item_option_new
  data:
    cat_item: "abc123"
    name: "employee_name"
    question_text: "Employee Name"
    type: 16
    order: 100
    mandatory: true
    active: true

# 3. Create laptop type variable
Tool: SN-Create-Record
Parameters:
  table_name: item_option_new
  data:
    cat_item: "abc123"
    name: "laptop_type"
    question_text: "Laptop Type"
    type: 5
    order: 200
    mandatory: true
    active: true
# Result: sys_id = "def456"

# 4. Add choices to laptop type
Tool: SN-Create-Record
Parameters:
  table_name: question_choice
  data:
    question: "def456"
    text: "MacBook Pro 14-inch"
    value: "macbook_14"
    order: 100

Tool: SN-Create-Record
Parameters:
  table_name: question_choice
  data:
    question: "def456"
    text: "Dell XPS 15"
    value: "dell_xps_15"
    order: 200

# 5. Create start date variable
Tool: SN-Create-Record
Parameters:
  table_name: item_option_new
  data:
    cat_item: "abc123"
    name: "start_date"
    question_text: "Employee Start Date"
    type: 9
    order: 300
    mandatory: true
    active: true

# 6. Create manager reference
Tool: SN-Create-Record
Parameters:
  table_name: item_option_new
  data:
    cat_item: "abc123"
    name: "reporting_manager"
    question_text: "Reporting Manager"
    type: 8
    reference: sys_user
    reference_qual: "active=true"
    order: 400
    mandatory: true
    active: true

最佳实践

  • 命名约定: 变量名使用 lowercase_with_underscores 格式
  • 按逻辑顺序排列变量: 将相关字段分组,并将必填字段放在前面
  • 使用变量集: 重用常见字段组(位置、审批人、日期)
  • 发布前测试: 创建测试请求以验证表单流程
  • 为条目编写说明: 使用描述字段为用户提供指引
  • 针对移动设备进行优化: 设计表单时考虑移动端用户
  • 选项达到 6 个或更多时使用 Type 5: 对于较长的选项列表,下拉框的用户体验更好
  • 选项为 2 至 5 个时使用 Type 1: 单选按钮一目了然

故障排除

表单中未显示变量

症状: 已创建变量,但未显示在目录表单上 原因:

  1. 变量未激活
  2. cat_item 引用错误
  3. UI 策略将其隐藏 解决方案:
Tool: SN-Query-Table
Parameters:
  table_name: item_option_new
  query: cat_item=[item_sys_id]^active=true
  fields: name,question_text,active,order
下拉列表中未显示选项

症状: 选择框或选项变量未显示任何选项 原因: 在 sys_choice 而非 question_choice 中创建了选项 解决方案: 目录变量应使用 question_choice 表

Tool: SN-Query-Table
Parameters:
  table_name: question_choice
  query: question=[variable_sys_id]
  fields: text,value,order,inactive
引用限定条件不起作用

症状: 引用变量显示所有记录,而非筛选后的记录 原因: reference_qual 语法无效 解决方案: 验证编码查询语法是否正确

目录中未显示条目

症状: 已创建条目,但未显示在目录中 原因:

  1. 条目未激活
  2. 类别错误
  3. 缺少目录关联 解决方案: 验证 active=true 且已填充 sc_catalogs

相关技能

  • catalog/variable-management - 高级变量配置
  • catalog/approval-workflows - 设置审批
  • catalog/request-fulfillment - 处理请求
  • admin/workflow-creation - 构建履行工作流

参考资料

评论

支持 Markdown