Function: CatalogItemRecordProducer(config)
Creates a Record Producer (sc_cat_item_producer) — a catalog item that creates a record in a
specified table when submitted. Extends CatalogItem with record creation and script capabilities.
Parameters
config
object
Record Producer configuration — target table, variables, fulfillment scripts, and catalog settings.
Properties:
-
$id (required):
string | number | ExplicitKey<string> -
name (required):
stringName to appear in the catalog. Required. -
table (required):
unknown | TableTarget table name where the record will be created (Required) -
active (optional, default: true):
booleanCheck box to make the item active (available to be ordered) -
allowEdit (optional, default: false):
booleanWhether to allow editing of the generated record after creation -
assignedTopics (optional):
(string | Record<'topic'>)[]The assigned topics for the catalog item -
availability (optional, default: 'desktopOnly'):
'both' | 'desktopOnly' | 'mobileOnly'The availability of the catalog item -
availableFor (optional):
(string | Record<'user_criteria'>)[]The users/groups this item is available for -
canCancel (optional, default: false):
booleanWhether the user can cancel the record producer submission -
catalogs (optional):
(string | Record<'sc_catalog'>)[]The catalogs the catalog item belongs to -
categories (optional):
(string | Record<'sc_category'>)[]Category for the item. Categories can only be selected after the Catalogs field is populated. -
checkedOut (optional):
booleanThe checked out for the catalog item -
description (optional):
stringThe detailed description of the catalog item -
hideAddToCart (optional, default: false):
booleanWhether add to cart is hidden for the catalog item -
hideAddToWishList (optional, default: false):
booleanWhether wishlist is hidden for the catalog item -
hideAttachment (optional):
booleanWhether attachments are hidden - cannot be true when mandatoryAttachment is true -
hideDeliveryTime (optional, default: false):
booleanWhether delivery time is hidden for the catalog item -
hideQuantitySelector (optional, default: false):
booleanWhether quantity selector is hidden for the catalog item -
hideSaveAsDraft (optional, default: false):
booleanWhether save as draft is hidden for the catalog item -
hideSP (optional, default: false):
booleanWhether to hide item from Service Portal -
icon (optional):
stringThe icon for the catalog item -
image (optional):
stringThe image for the catalog item -
mandatoryAttachment (optional):
booleanWhether mandatory attachments are required for the catalog item -
meta (optional):
string[]Search tags for the catalog item -
mobilePicture (optional):
stringThe mobile picture for the catalog item -
mobilePictureType (optional, default: 'desktopPicture'):
'desktopPicture' | 'mobilePicture' | 'noPicture'Whether to use the mobile picture type -
model (optional):
string | Record<'cmdb_model'>The model of the catalog item -
notAvailableFor (optional):
(string | Record<'user_criteria'>)[]The users/groups this item is not available for -
order (optional, default: 0):
numberThe order of the catalog item -
owner (optional):
string | Record<'sys_user'>The owner for the catalog item -
picture (optional):
stringThe picture for the catalog item -
postInsertScript (optional):
string | (producer: RecordProducerContext, current: GlideRecord, cat_item: RecordProducerDefinition) => voidScript executed AFTER the record is generated. Safe to use current.update() here. Useproducer.var_nameto access variables. Usecat_itemto access the Record Producer definition. -
redirectUrl (optional, default: 'generatedRecord' Options: 'generatedRecord', 'catalogHomePage'):
'generatedRecord' | 'catalogHomePage'Where to redirect after record creation -
roles (optional):
(string | Role)[]Roles for a catalog item -
saveOptions (optional):
stringOptions for saving the record producer (advanced configuration) -
saveScript (optional):
string | (producer: RecordProducerContext, current: GlideRecord, cat_item: RecordProducerDefinition) => voidScript executed at every step save in Catalog Builder. Executed BEFORE the main script. Usecurrentto access the GlideRecord. -
script (optional):
string | (producer: RecordProducerContext, current: GlideRecord) => voidServer-side script executed BEFORE the record is generated. Useproducer.var_nameto access variables. Usecurrentto access the GlideRecord being produced. Do NOT use current.update() or current.insert(). -
shortDescription (optional):
stringA short description of the catalog item -
showVariableHelpOnLoad (optional, default: false):
booleanWhether to show variable help on load -
startClosed (optional, default: false):
booleanWhether to start closed -
state (optional):
StateThe state for the catalog item -
variables (optional):
Record<string, AnyVariable>The variables for the catalog item -
variableSets (optional):
object[]The variable sets the catalog item belongs to -
version (optional, default: 1):
numberThe version of the catalog item -
view (optional):
string | Record<'sys_ui_view'>The view for the catalog item
See
Examples
Basic Record Producer
Create a record producer with checkbox variables and pricing
// Source: packages/api/tests/service-catalog-plugin/fluent/record-producer-variables/create/checkbox.now.ts
/**
* @title Basic Record Producer
* @description Create a record producer with checkbox variables and pricing
*/
import { CatalogItemRecordProducer, CheckboxVariable } from '@servicenow/sdk/core'
export const BasicRecordProducer = CatalogItemRecordProducer({
$id: Now.ID['checkbox_pricing_rp'],
name: 'Checkbox Pricing Test',
table: 'task',
shortDescription: 'Test checkbox with pricing',
description: 'Record producer with checkbox variables and pricing details',
catalogs: ['e0d08b13c3330100c8b837659bba8fb4'],
variables: {
premiumSupport: CheckboxVariable({
question: 'Premium Support',
order: 1,
selectionRequired: true,
pricingDetails: [
{
amount: 100,
currencyType: 'USD',
field: 'price_if_checked',
},
],
}),
rushDelivery: CheckboxVariable({
question: 'Rush Delivery',
order: 2,
selectionRequired: false,
}),
},
})
Record Producer with SelectBox Variables
Create a record producer with selectbox variables using table-based and custom choices
// Source: packages/api/tests/service-catalog-plugin/fluent/record-producer-variables/create/selectbox.now.ts
/**
* @title Record Producer with SelectBox Variables
* @description Create a record producer with selectbox variables using table-based and custom choices
*/
import { CatalogItemRecordProducer, SelectBoxVariable } from '@servicenow/sdk/core'
export const SelectBoxRecordProducer = CatalogItemRecordProducer({
$id: Now.ID['selectbox_test_rp'],
name: 'SelectBox Test',
table: 'task',
shortDescription: 'Test selectbox with choices and pricing',
description: 'Record producer with selectbox variables',
catalogs: ['e0d08b13c3330100c8b837659bba8fb4'],
variables: {
// SelectBox sourced from an existing table/field
priorityFromTable: SelectBoxVariable({
question: 'Priority (From Table)',
order: 1,
choiceTable: 'task',
choiceField: 'priority',
}),
// SelectBox with custom choices and pricing details
supportLevel: SelectBoxVariable({
question: 'Support Level',
order: 2,
choices: {
basic: {
label: 'Basic Support',
sequence: 1,
inactive: false,
pricingDetails: [
{
field: 'misc',
amount: 50,
currencyType: 'USD',
},
],
},
standard: {
label: 'Standard Support',
sequence: 2,
inactive: false,
pricingDetails: [
{
field: 'misc',
amount: 100,
currencyType: 'USD',
},
{
field: 'rec_misc',
amount: 25,
currencyType: 'USD',
},
],
},
premium: {
label: 'Premium Support',
sequence: 3,
inactive: false,
},
},
}),
// SelectBox with simple choices (no pricing)
deliveryMethod: SelectBoxVariable({
question: 'Delivery Method',
order: 3,
choices: {
email: {
label: 'Email',
sequence: 1,
inactive: false,
},
download: {
label: 'Download',
sequence: 2,
inactive: false,
},
physical: {
label: 'Physical Media',
sequence: 3,
inactive: false,
},
},
}),
},
})
Record Producer with Multiple Variable Types
Create a record producer showcasing various variable types
// Source: packages/api/tests/service-catalog-plugin/fluent/record-producer-variables/create/basic.now.ts
/**
* @title Record Producer with Multiple Variable Types
* @description Create a record producer showcasing various variable types
*/
import {
CatalogItemRecordProducer,
CheckboxVariable,
DateVariable,
DateTimeVariable,
EmailVariable,
ListCollectorVariable,
MaskedVariable,
MultiLineTextVariable,
ReferenceVariable,
SelectBoxVariable,
SingleLineTextVariable,
UrlVariable,
YesNoVariable,
} from '@servicenow/sdk/core'
export const MultiVariableRecordProducer = CatalogItemRecordProducer({
$id: Now.ID['software_install_rp'],
name: 'Software Installation',
table: 'task',
shortDescription: 'Request software installation',
description: 'Use this form to request installation of software on your company device.',
meta: ['software', 'installation', 'IT'],
variables: {
checkbox: CheckboxVariable({
question: 'Agree to Terms',
order: 1,
}),
date: DateVariable({
question: 'Preferred Date',
order: 2,
}),
dateTime: DateTimeVariable({
question: 'Scheduled Date/Time',
order: 3,
}),
email: EmailVariable({
question: 'Contact Email',
order: 4,
}),
listCollector: ListCollectorVariable({
question: 'Notify Users',
order: 5,
listTable: 'sys_user',
referenceQual: 'active=true',
}),
masked: MaskedVariable({
question: 'License Key',
order: 6,
useConfirmation: false,
useEncryption: true,
}),
multilineText: MultiLineTextVariable({
question: 'Additional Notes',
order: 7,
}),
reference: ReferenceVariable({
question: 'Assigned To',
order: 8,
referenceTable: 'sys_user',
referenceQualCondition: 'active=true^EQ',
}),
selectBox: SelectBoxVariable({
question: 'Priority',
order: 9,
choiceTable: 'task',
choiceField: 'state',
}),
singleLineText: SingleLineTextVariable({
question: 'Software Name',
order: 10,
}),
url: UrlVariable({
question: 'Download URL',
order: 11,
}),
yesNo: YesNoVariable({
question: 'Is this urgent?',
includeNone: true,
order: 12,
}),
},
})