Retrieve ServiceNow Table Records

Action ID: servicenow:now:table:retrieveRecords
NPM Package:

@backstage-community/plugin-scaffolder-backend-module-servicenow

Description

Retrieves multiple records for the specified table

Input Schema

PropertyTypeDescriptionRequired
tableNamestring-
sysparmViewstring-
sysparmLimitnumber-
sysparmQuerystring-
sysparmFieldsarray-
sysparmNoCountboolean-
sysparmDisplayValuestring-
sysparmQueryCategorystring-
sysparmQueryNoDomainboolean-
sysparmExcludeReferenceLinkboolean-
sysparmSuppressPaginationHeaderboolean-

Output Schema

No output schema defined for this action.

Usage Examples

Retrieve high-priority open incidents with selected fields

Fetch a template, then retrieve open incidents with high priority for a specific service CI. Use this when you need a concise incident list during scaffolding. Uses fetch:template and debug:log for context.

Copy
steps:
  - id: fetch-base
    action: fetch:template
    input:
      url: https://github.com/acme/templates/service-skeleton/archive/main.zip
      targetPath: .
      values:
        serviceName: ${{ parameters.serviceName }}

  - id: retrieve-incidents
    action: servicenow:now:table:retrieveRecords
    input:
      tableName: incident
      sysparmQuery: >-
        active=true^priority<=2^cmdb_ci=${{ parameters.serviceCiSysId }}^ORDERBYDESCsys_updated_on
      sysparmDisplayValue: "false"
      sysparmExcludeReferenceLink: true
      sysparmFields:
        - number
        - short_description
        - priority
        - state
        - assignment_group
        - sys_updated_on
      sysparmLimit: 50

  - id: log-done
    action: debug:log
    input:
      message: Retrieved high-priority incidents for ${{ parameters.serviceName }}

Retrieve change requests for an assignment group with display values

Get change requests scheduled this week for a given assignment group with readable display values. Use this to surface upcoming changes owned by a team.

Copy
steps:
  - id: fetch-base
    action: fetch:template
    input:
      url: https://github.com/acme/templates/change-dashboard/archive/main.zip
      targetPath: .

  - id: retrieve-changes
    action: servicenow:now:table:retrieveRecords
    input:
      tableName: change_request
      sysparmQuery: >-
        stateIN-5,0,1^assignment_group=${{ parameters.assignmentGroupSysId }}^start_dateONThis week@javascript:gs.beginningOfThisWeek()@javascript:gs.endOfThisWeek()^ORDERBYstart_date
      sysparmDisplayValue: "true"
      sysparmExcludeReferenceLink: true
      sysparmSuppressPaginationHeader: true
      sysparmFields:
        - number
        - short_description
        - state
        - assignment_group
        - start_date
        - end_date
      sysparmLimit: 25

  - id: log-done
    action: debug:log
    input:
      message: Retrieved change requests for assignment group ${{ parameters.assignmentGroupName }}

Retrieve CMDB services across domains without count

Query CMDB business services while ignoring domain partitions and skipping the count header. Use this for faster queries across multi-domain instances.

Copy
steps:
  - id: fetch-base
    action: fetch:template
    input:
      url: https://github.com/acme/templates/ops-insights/archive/main.zip
      targetPath: .

  - id: retrieve-services
    action: servicenow:now:table:retrieveRecords
    input:
      tableName: cmdb_ci_service
      sysparmQuery: >-
        install_status=1^operational_status=1^business_criticalityIN1,2^ORDERBYname
      sysparmDisplayValue: "false"
      sysparmQueryNoDomain: true
      sysparmNoCount: true
      sysparmQueryCategory: default
      sysparmFields:
        - sys_id
        - name
        - business_criticality
        - used_for
        - owning_group
        - sys_domain
      sysparmLimit: 100

  - id: log-done
    action: debug:log
    input:
      message: Retrieved active CMDB services for portfolio reporting

Retrieve active users in a department with all display values

Retrieve active users from a department and return both raw and display values. Use this when you need readable references while keeping raw sys_ids.

Copy
steps:
  - id: fetch-base
    action: fetch:template
    input:
      url: https://github.com/acme/templates/access-report/archive/main.zip
      targetPath: .

  - id: retrieve-users
    action: servicenow:now:table:retrieveRecords
    input:
      tableName: sys_user
      sysparmQuery: >-
        active=true^department=${{ parameters.departmentSysId }}^ORDERBYname
      sysparmDisplayValue: "all"
      sysparmFields:
        - sys_id
        - name
        - user_name
        - email
        - manager
        - department
      sysparmView: ess
      sysparmLimit: ${{ parameters.userLimit }}

  - id: log-done
    action: debug:log
    input:
      message: Retrieved active users for department ${{ parameters.departmentName }}

Retrieve onboarding cases from a custom table with a templated query

Query a custom onboarding table using a templated encoded query and a specific view. Use this to integrate onboarding data into generated documentation.

Copy
steps:
  - id: fetch-base
    action: fetch:template
    input:
      url: https://github.com/acme/templates/onboarding-kit/archive/main.zip
      targetPath: .

  - id: retrieve-onboarding-cases
    action: servicenow:now:table:retrieveRecords
    input:
      tableName: x_acme_onboarding_case
      sysparmQuery: ${{ parameters.onboardingEncodedQuery }}
      sysparmDisplayValue: "false"
      sysparmExcludeReferenceLink: false
      sysparmSuppressPaginationHeader: false
      sysparmView: mobile
      sysparmFields:
        - number
        - short_description
        - state
        - requested_for
        - opened_at
        - assignment_group
      sysparmLimit: 100

  - id: log-done
    action: debug:log
    input:
      message: Retrieved onboarding cases matching provided query