Interceptor
Creates an Interceptor (sys_wizard) that presents a question/decision panel before a user creates a new record on an intercepted table, guiding them through a branching flow of Answers to the right destination form, URL, or follow-up question.
Signature
Interceptor(config)
Usage
import { Interceptor } from '@servicenow/sdk/core'
Interceptor({
name: 'Choose request type',
question: 'What would you like to create?',
answers: [
{
$id: Now.ID['choose-request-type-hardware'],
answer: 'Hardware request',
type: 'answer',
targetUrl: 'sc_cat_item.do?sys_id=-1',
order: 100,
active: true,
},
],
})
Parameters
config
Interceptor
an object containing api properties:
Properties:
-
name (required):
stringInternal label for this question panel. Not shown to the end user. Identifies the record — twoInterceptors with the samenamecoalesce into a single record. Renaming an existing Interceptor creates a new record on the instance and deletes the old one -
question (optional):
stringQuestion text presented to the user -
backPanel (optional):
string | Record<'sys_wizard'> | InterceptorPrevious question/panel in the flow. Reference tosys_wizard; accepts a raw sys_id string, aRecord<'sys_wizard'>reference, or anInterceptor(...)expression -
nextPanel (optional):
string | Record<'sys_wizard'> | InterceptorDefault next question/panel in the flow, used when the selected answer doesn't specify its ownnextQuestion. Reference tosys_wizard; accepts a raw sys_id string, aRecord<'sys_wizard'>reference, or anInterceptor(...)expression -
intercepts (optional):
string*.dopage path this Interceptor triggers on instead of the table's default new-record form, e.g.'incident.do' -
answers (optional):
InterceptorAnswer[]Answer options presented to the user for this question- $id (required):
string | number | ExplicitKey<string>-- Required per-answer identifier;sys_wizard_answerhas no safe natural key - name (optional):
string-- Internal label; when omitted, the build plugin copiesanswerinto the generated record - answer (optional):
string-- Text shown to the user for this option ("User Prompt" on the platform form). Not displayed whentypeis'button' - type (optional, default:
'answer'):'answer' | 'leadingQuestion' | 'multipleChoice' | 'yesNo' | 'freeformText' | 'button' | 'externalChoice' | string-- Controls which of this answer's other fields are used. - targetUrl (optional):
string-- Destination URL. Used whentypeis'answer' - nextQuestion (optional):
string | Record<'sys_wizard'> | Interceptor-- Next Interceptor question. Used whentypeis'leadingQuestion'. Accepts a raw sys_id string, aRecord<'sys_wizard'>, or anInterceptor(...)expression. - buttonLabel (optional):
string-- Visible text shown on the button. Used whentypeis'button'; theanswerfield is not displayed for buttons - table (optional):
keyof Tables-- Table whose choice-list values (sys_choicerows) to source from. Used whentypeis'externalChoice'. This pulls the dropdown options defined forelementon this table — it does NOT query records (rows) from the table itself. In a scoped app, must be in the same scope as this definition (prefixed<scope>_); to target an out-of-box table, use a global-scope app or a scoped table that extends it. Not validated against real table existence at build time — querysys_db_objecton the target instance to confirm the table exists before authoring - element (optional):
string-- Choice column ontablewhosesys_choicedropdown values populate the answer's options. Used whentypeis'externalChoice'. The platform reads fromsys_choicerows for this column — it does not list records from the table. Liketable, this is a plain string not validated against the real column at build time — querysys_dictionary(filtered byname=<table>^element=<element>) on the target instance to confirm the column exists and has adropdownchoice type before authoring - dependentValue (optional):
string-- Optional value of the parent field whenelementis a dependent choice list ontable(e.g.subcategorydepending oncategory). Used whentypeis'externalChoice'; omit for simple choice lists likestate - script (optional):
string-- Script executed when this answer is selected. Not gated to a specifictype - roles (optional):
(string | Role)[]-- Role names orRoleobjects allowed to see this answer at runtime. Not enforced at build time — this is a runtime visibility filter, not a build-time access check. The underlyingrolesfield is ACL- and dictionary-restricted to theadminrole for read/write on the platform's standard UI; Fluent can still set it at install time via the generated XML (which bypasses UI-level ACLs), but a human editing the value afterward through the platform form needs theadminrole - order (optional, default:
100):number-- Sort order among sibling answers under the same question — give each sibling a distinct value or their display order becomes unpredictable - active (optional, default:
true):boolean-- Whether this answer is presented to the user - payloadName (optional):
string-- Platform-internal payload correlation name
- $id (required):
-
protectionPolicy (optional):
'read' | 'protected'Controls edit/view access for other developers after the application is installed.'read': Others can see the record but not change it'protected': Others cannot change this record- Omit to allow other developers to customize this record
Examples
Basic Interceptor question
A question with two direct-answer options.
/**
* @title Basic Interceptor question
* @description A question with two direct-answer options
*/
import { Interceptor } from '@servicenow/sdk/core'
Interceptor({
name: 'Choose request type',
question: 'What would you like to create?',
answers: [
{
$id: Now.ID['interceptor-basic-hardware'],
answer: 'Hardware request',
type: 'answer',
targetUrl: 'sc_cat_item.do?sys_id=-1&sysparm_category=hardware',
order: 100,
active: true,
},
{
$id: Now.ID['interceptor-basic-software'],
answer: 'Software request',
type: 'answer',
targetUrl: 'sc_cat_item.do?sys_id=-1&sysparm_category=software',
order: 200,
active: true,
},
],
})
Interceptor with multiple choice answer
/**
* @title Interceptor with multiple choice answer
* @description An answer with sub-choices created via the Record API
*/
import { Interceptor, Record } from '@servicenow/sdk/core'
Interceptor({
name: 'Multiple choice priority',
question: 'How urgent is this?',
answers: [
{
$id: Now.ID['interceptor-with-multiple-choice-priority'],
answer: 'Select a priority level',
type: 'multipleChoice',
order: 100,
active: true,
},
],
})
Interceptor with leading question
An answer that advances to another Interceptor question instead of navigating to a URL directly.
/**
* @title Interceptor with leading question
* @description An answer that advances to another Interceptor question instead of navigating to a URL directly
*/
import { Interceptor } from '@servicenow/sdk/core'
Interceptor({
name: 'Leading question chooser',
question: 'What would you like to create?',
answers: [
{
$id: Now.ID['interceptor-with-leading-question-hardware'],
answer: 'Hardware request',
type: 'leadingQuestion',
// sys_id of the target question, captured after deploying it separately
nextQuestion: 'ce0487629b954f3c9618b3b901865ea2',
order: 100,
active: true,
},
],
})
Interceptor with external choice answer
Sources selectable values dynamically from a choice list on another table.
/**
* @title Interceptor with external choice answer
* @description Sources selectable values dynamically from a choice list on another table
*/
import { Interceptor } from '@servicenow/sdk/core'
Interceptor({
name: 'External choice status',
question: 'Select a status',
answers: [
{
$id: Now.ID['interceptor-with-external-choice-status'],
answer: 'Choose from status list',
type: 'externalChoice',
table: 'incident',
element: 'state',
order: 100,
active: true,
},
],
})
Interceptor with external choice from a dependent choice list
Use dependentValue only when the chosen element is itself a dependent choice list (e.g. subcategory depends on category on incident).
/**
* @title Interceptor with external choice from a dependent choice list
* @description Scopes a dependent choice list by supplying the parent-field value
*/
import { Interceptor } from '@servicenow/sdk/core'
Interceptor({
name: 'External choice dependent subcategory',
question: 'Which subcategory?',
answers: [
{
$id: Now.ID['interceptor-with-external-choice-subcategory'],
answer: 'Choose a subcategory',
type: 'externalChoice',
table: 'incident',
element: 'subcategory',
dependentValue: 'Network',
order: 100,
active: true,
},
],
})
Interceptor with yesNo and freeformText answers
Captures a yes/no selection and a free-text input from the user. Both types require payloadName — it is the only field with runtime effect.
/**
* @title Interceptor with yesNo and freeformText answers
* @description Captures a yes/no selection and a free-text input from the user
*/
import { Interceptor } from '@servicenow/sdk/core'
Interceptor({
name: 'Input capture details',
question: 'Additional details',
answers: [
{
$id: Now.ID['interceptor-with-input-capture-urgent'],
type: 'yesNo',
answer: 'Is this request urgent?',
payloadName: 'urgent',
order: 100,
},
{
$id: Now.ID['interceptor-with-input-capture-justification'],
type: 'freeformText',
answer: 'Justification',
payloadName: 'justification',
order: 200,
},
],
})
Advanced Interceptor
Combines direct answers, a leading question, a multiple choice answer, and a scripted button answer in one question.
/**
* @title Advanced Interceptor
* @description Combines direct answers, a leading question, a multiple choice answer, and a scripted button answer in one question
*/
import { Interceptor } from '@servicenow/sdk/core'
Interceptor({
name: 'Advanced request chooser',
question: 'What would you like to create today?',
intercepts: 'incident.do',
backPanel: '82ca0be019af4745b235703c4c68a675',
answers: [
{
$id: Now.ID['interceptor-advanced-direct'],
answer: 'Report an issue',
type: 'answer',
targetUrl: 'incident.do?sys_id=-1',
order: 100,
active: true,
},
{
$id: Now.ID['interceptor-advanced-leading'],
answer: 'Request hardware',
type: 'leadingQuestion',
nextQuestion: 'ce0487629b954f3c9618b3b901865ea2',
order: 200,
active: true,
},
{
$id: Now.ID['interceptor-advanced-choice'],
answer: 'Select a priority',
type: 'multipleChoice',
order: 300,
active: true,
},
{
$id: Now.ID['interceptor-advanced-button'],
type: 'button',
buttonLabel: 'Escalate',
script: "current.priority = '1'; current.update();",
roles: ['itil'],
order: 400,
active: true,
},
],
})