CatalogItemRecordProducer
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.
Signature
CatalogItemRecordProducer(config)
Properties
-
$id (required):
string | number | ExplicitKey<string> -
name (required):
stringName to appear in the catalog. -
active (optional):
booleanWhether the item is active. Default:true. -
allowEdit (optional):
booleanWhether to allow editing of the generated record after creation. Default:false. -
assignedTopics (optional):
(string | Record<'topic'>)[]sys_id of existing topics. Controls ESC portal visibility. -
availability (optional):
'desktopOnly' | 'both' | 'mobileOnly'Platform availability. Default:'desktopOnly'. -
availableFor (optional):
(string | Record<'user_criteria'>)[]sys_id of user criteria for availability. -
canCancel (optional):
booleanWhether the user can cancel the record producer submission. Default:false. -
catalogs (optional):
(string | Record<'sc_catalog'>)[]sys_id of existing catalogs. Use queries to find. -
categories (optional):
(string | Record<'sc_category'>)[]sys_id of existing categories. Use queries to find. Can only be selected aftercatalogsis populated. -
checkedOut (optional):
booleanWhether the item is checked out. -
description (optional):
stringDetailed description shown on the item page. -
hideAddToCart (optional):
booleanHides "Add to Cart" button. Default:false. -
hideAddToWishList (optional):
booleanHides "Add to Wishlist". Default:false. -
hideAttachment (optional):
booleanHides attachment section. Cannot betruewhenmandatoryAttachmentistrue. Default:false. -
hideDeliveryTime (optional):
booleanHides delivery time. Default:false. -
hideQuantitySelector (optional):
booleanHides quantity selection. Default:false. -
hideSaveAsDraft (optional):
booleanHides "Save as Draft". Default:false. -
hideSP (optional):
booleanHides from Service Portal. Default:false. -
icon (optional):
stringIcon for the catalog item. -
image (optional):
stringImage for the catalog item. -
makeItemNonConversational (optional):
booleanPrevents virtual agent ordering. Default:false. -
mandatoryAttachment (optional):
booleanRequires an attachment. ForceshideAttachmenttofalsewhen set. Default:false. -
meta (optional):
string[]Search tags for the catalog item. -
mobilePicture (optional):
stringMobile picture for the catalog item. -
mobilePictureType (optional):
'desktopPicture' | 'mobilePicture' | 'noPicture'Mobile picture type. Default:'desktopPicture'. -
model (optional):
string | Record<'cmdb_model'>Model of the catalog item. -
noSearch (optional):
booleanExcludes item from portal search results. Default:false. -
notAvailableFor (optional):
(string | Record<'user_criteria'>)[]sys_id of user criteria for restrictions (overridesavailableFor). -
order (optional):
numberOrder of the catalog item. Default:0. -
owner (optional):
string | Record<'sys_user'>Owner for the catalog item. -
picture (optional):
stringPicture for the catalog item. -
postInsertScript (optional):
((producer: RecordProducerContext, current: GlideRecord, cat_item: RecordProducerDefinition) => void) | stringScript executed AFTER the record is generated. Safe to callcurrent.update(). Useproducer.var_nameto access variables andcat_itemto access the Record Producer definition. -
protectionPolicy (optional):
'read' | 'protected'Controls edit/view access for other developers after the application is installed.read: others can see the script logic but not change it.protected: others cannot change this record. Omit to allow other developers to customize this record. -
redirectUrl (optional):
'generatedRecord' | 'catalogHomePage'Where to redirect after record creation. Default:'generatedRecord'. -
roles (optional):
(string | Role)[]Roles for catalog item access. -
saveOptions (optional):
stringOptions for saving the record producer (advanced configuration). -
saveScript (optional):
((producer: RecordProducerContext, current: GlideRecord, cat_item: RecordProducerDefinition) => void) | stringScript executed at every step save in Catalog Builder. Executed BEFORE the main script. Usecurrentto access the GlideRecord. -
script (optional):
((producer: RecordProducerContext, current: GlideRecord) => void) | stringServer-side script executed BEFORE the record is generated. Useproducer.var_nameto access variables andcurrentto access the GlideRecord being produced. Do NOT usecurrent.update()orcurrent.insert(). -
shortDescription (optional):
stringBrief summary shown in catalog listings. -
showVariableHelpOnLoad (optional):
booleanShows help text by default. Default:false. -
startClosed (optional):
booleanStart closed. Default:false. -
state (optional):
'published' | 'draft' | 'publishing' | 'in_review' | 'reviewed'State of the catalog item. -
table (required):
TableName | TableTarget table where the record will be created. Accepts a table name string or aTable()definition. Example:'incident','change_request','problem'. -
variables (optional):
objectVariable definitions for the form. -
variableSets (optional):
{ variableSet: string | VariableSet; order: number }[]Variable set references. -
version (optional):
numberVersion of the catalog item. Default:1. -
view (optional):
string | Record<'sys_ui_view'>View for the catalog item. -
visibleBundle (optional):
booleanBundle visibility. Default:true. -
visibleGuide (optional):
booleanGuide visibility. Default:true. -
visibleStandalone (optional):
booleanStandalone visibility. Default:true.
Field Mapping Methods
| Scenario | Recommended Method |
|---|---|
| Simple text/choice mapping | mapToField: true |
| System values (gs.getUserID()) | Script |
| Conditional logic | Script |
| Calculated values | Script |
| Variables in Variable Sets | Script |
Script Types
| Script | Timing | Can call update()? |
|---|---|---|
script | Before insert | No |
postInsertScript | After insert | Yes |
saveScript | On step save | No |
Available Script Objects
| Object | Description |
|---|---|
current | GlideRecord of the record being created |
producer.var_name | Form variable values |
cat_item | Record Producer definition (postInsertScript only) |
gs | GlideSystem |
Script Rules
- Never call
current.update()orcurrent.insert()in pre-insert script - Never call
current.setAbortAction() - Never set
current.sys_class_name - Use
postInsertScriptfor post-creation updates, related records, notifications
Unsupported Tables
Do not create record producers for:
sc_request,sc_req_item,sc_task— Use Catalog Items instead.
Common User Requests Mapping
| User Request | Agent Implementation |
|---|---|
| "Report an incident from catalog" | Record Producer targeting incident table |
| "Submit a change request" | Record Producer targeting change_request table |
| "Report a problem" | Record Producer targeting problem table |
| "Create record with auto-fill" | Record Producer with pre-insert script |
Quick Reference
ALWAYS
- Use
mapToField: truefor simple field mappings - Use
Now.include(...)for external script files - Use
postInsertScriptfor post-creation updates and related records - Set
redirectUrl: "generatedRecord"to redirect to the created record
NEVER
- Call
current.update()orcurrent.insert()in pre-insert script - Call
current.setAbortAction()in Record Producer scripts - Set
current.sys_class_namein scripts - Create Record Producers for
sc_request,sc_req_item,sc_task
Usage
When to Use Record Producer vs Catalog Item
Use CatalogItemRecordProducer when the catalog submission should create a record in a specific table — incident, change request, task, or a custom table. Use CatalogItem for items that fulfill via order tasks and fulfillment workflows.
Mapping Variables to Record Fields
The mapToField and field properties on variables automatically populate fields on the created record from user-entered variable values. This is the primary way to transfer form input to the target record — no script required.
See the Service Catalog Variables Guide for the full list of variable properties including mapToField and field.
Script Execution Order
When a record producer is submitted, scripts run in this order:
| Order | Script | When | cat_item available? |
|---|---|---|---|
| 1 | saveScript | On each step save in Catalog Builder | Yes |
| 2 | script | Before the record is inserted | No |
| — | (mapToField applied automatically) | After script, before postInsertScript | — |
| 3 | postInsertScript | After the record is inserted | Yes |
Available Script Objects
| Object | Type | Available in |
|---|---|---|
producer | RecordProducerContext | All scripts |
current | GlideRecord | All scripts |
cat_item | RecordProducerDefinition | saveScript, postInsertScript only |
cat_item is not injected into script. If you need the Record Producer definition after insert, use postInsertScript.
See the Service Catalog Guide — Record Producer section for a full walkthrough of script patterns.
See
- Service Catalog Guide — Record Producer patterns,
mapToFieldand script interaction - Service Catalog Variables Guide — All variable types and variable properties (
mapToField,field, etc.) - https://docs.servicenow.com/csh?topicname=c_CreatingARecordProducer.html&version=latest