Service Catalog API - ServiceNow Fluent

  • Rversion finale: Australia
  • Mis à jour 12 mars 2026
  • 32 minutes de lecture
  • The Service Catalog API defines catalog items [sc_cat_item] and related aspects of service catalogs, including categories, record producers, variables, catalog client scripts, catalog UI policies, and variable sets.

    For general information about service catalogs, see Service Catalog.

    CatalogItem object

    Create a catalog item [sc_cat_item] that users can request from a service catalog.

    A catalog item must reference a flow, workflow, or execution plan that defines how the item request is fulfilled.

    Tableau 1. Properties
    Name Type Description
    $id String or Number Required. A unique ID for the metadata object. When you build the application, this ID is hashed into a unique sys_id. For more information, see ServiceNow Fluent language constructs.

    Format: Now.ID['String' or Number]

    name String Required. A name for the item that appears in the catalog.
    flow Reference or String The variable identifier or sys_id of a flow [sys_hub_flow] that defines how the request is fulfilled. Use Now.ref() to reference a project-defined flow, or provide a sys_id string for an existing platform flow. To define a flow, use the Flow API - ServiceNow Fluent.
    Remarque :
    This is the recommended fulfillment method for catalog items. When flow, workflow, and executionPlan are all specified, the system uses the flow.
    executionPlan Reference or String The variable identifier or sys_id of an execution plan [sc_cat_item_delivery_plan] that defines how the request is fulfilled. To define an execution plan, use the Record API - ServiceNow Fluent.
    workflow String The sys_id of a legacy workflow [wf_workflow] that defines how the item request is fulfilled. Use the flow property for new implementations.
    accessType String The user access required to request the item.
    Valid values:
    • restricted: Only users who have access to the item can request the item.
    • unrestricted: Users who do not have access to the item can request the item. For information about delegated request experience, see Delegated request experience.
    Remarque :
    This functionality is only applicable when the item has a Requested For variable.

    Default: restricted

    location Reference or String The variable identifier or sys_id of a location [cmn_location] where the item is provided. To define a location, use the Record API - ServiceNow Fluent.
    vendor Reference or String The variable identifier or sys_id of a vendor associated with the item. To define a vendor, use the Record API - ServiceNow Fluent.
    active Boolean Flag that indicates whether the item is able to be requested.

    Default: true

    availability String The type of device on which the item displays.
    Valid values:
    • desktopOnly: The item displays only on desktop devices.
    • mobileOnly: The item displays only on mobile devices.
    • both: The item displays on both desktop and mobile devices.

    Default: desktopOnly

    checkedOut Boolean Flag that indicates whether the item is checked out for editing.

    Default: false

    description String A detailed description of the item that displays in the catalog when a user selects the item or clicks the associated Preview link.

    You can embed videos, images, links to internal knowledge base (KB) articles, and links to external sources of information and instruction documentation.

    meta Array A list of metadata tags used to aid in searches related to the item.
    Remarque :
    The meta property is used only for Zing text indexing and search engine and not for AI Search.
    model Reference or String The variable identifier or sys_id of a product model [cmdb_model] associated with the item. To define a product model, use the Record API - ServiceNow Fluent.
    order Number The order in which the item appears within its category.

    Default: 0

    owner Reference or String The variable identifier or sys_id of a user [sys_user] who owns the item and has edit access to it​. To define a user, use the Record API - ServiceNow Fluent.
    roles Array A list of variable identifiers or sys_ids of roles [sys_user_role] that can access the item.​ To define a role, use the Role API - ServiceNow Fluent.
    shortDescription String A short description of the item that appears on the service catalog homepage, search results, and the title bar of the order form.
    showVariableHelpOnLoad Boolean Flag that indicates whether the item displays variable help text by default.

    Default: false

    startClosed Boolean Flag that indicates whether to starts the item in a collapsed state.

    Default: false

    state String The publication state of the item, such as draft or published.
    variables Object The variable definitions for the item that provide options for requesting it. Each variable type has a specific function. For example:
    variables: {
        laptopType: SelectBoxVariable({
          question: "Laptop Type",
          choices: {
            standard: { label: "Standard Laptop", sequence: 1 },
            developer: { label: "Developer Workstation", sequence: 2 }
          },
          mandatory: true,
          order: 100
        }),
        justification: MultiLineTextVariable({
          question: "Business Justification",
          mandatory: true,
          order: 200
        })
    }

    For general information about catalog, see Service catalog variables.

    version Number A version of the item.

    Default: 1

    view Reference or String Required. The variable identifier or name of the UI view [sys_ui_view] which applies, or the default view.

    To define a UI view, use the Record API - ServiceNow Fluent.

    To use the default view (default_view), you must import it:
    import { default_view } from '@servicenow/sdk/core'
    image String Deprecated. An image for the item.
    icon String An image file that displays as an icon beside the item name in the catalog.

    Use a 27x27 pixel image. If no image is uploaded, the default icon appears.

    picture String An image file to display as a picture of the item.
    mobilePicture String An image to display as a picture of the item on mobile devices.

    This property applies only if the value of the mobilePictureType is mobilePicture.

    mobilePictureType String The type of picture to display for the item on mobile devices.
    Valid values:
    • desktopPicture: Use the image from the picture property.
    • mobilePicture: Use the image from the mobilePicture property.
    • noPicture: The item doesn't display a picture on mobile devices.

    Default: desktopPicture

    deliveryPlanScript Script Deprecated. Use the executionPlan property instead.
    deliveryTime Object The estimated time to deliver the item.

    Format: deliveryTime: { days: Number, hours: Number })

    entitlementScript Script A script that defines entitlement for the item.
    makeItemNonConversational Boolean Flag that indicates whether to prevent the ability to request the item from a conversational experience such as Virtual Agent. If true, the item can be requested from a conversational experience.

    Default: false

    visibleBundle Boolean Flag that indicates whether item is visible in saved bundles.

    Default: true

    visibleGuide Boolean Flag that indicates whether item is visible in order guides.

    Default: true

    visibleStandalone Boolean Flag that indicates whether the standalone view is visible.

    Default: true

    hideAddToCart Boolean Flag that indicates whether to hide the Add to Cart button.

    Default: false

    hideAddToWishList Boolean Flag that indicates whether to hide the Add to Wishlist button.

    Default: false

    hideDeliveryTime Boolean Flag that indicates whether to hide the delivery time.

    Default: false

    hideQuantitySelector Boolean Flag that indicates whether to hide the Quantity field.

    Default: false

    hideSaveAsDraft Boolean Flag that indicates whether to hide the Save as Draft button.

    Default: false

    hideSP Boolean Flag that indicates whether to hide an item on Service Portal.

    Default: false

    mandatoryAttachment Boolean Flag that indicates whether to require adding an attachment to submit a request.

    Default: false

    hideAttachment Boolean Flag that indicates whether to hide the attachment section and not support adding attachments.

    Default: false

    noCart Boolean Deprecated. Flag that indicates whether to hide the shopping cart.

    Default: false

    noOrder Boolean Deprecated. Flag that indicates whether to hide the order option.

    Default: false

    noOrderNow Boolean Deprecated. Flag that indicates whether to hide the order now option.

    Default: false

    noProceedCheckout Boolean Deprecated. Flag that indicates whether to hide the checkout process.

    Default: false

    noQuantity Boolean Deprecated. Flag that indicates whether to hide the quantity field.

    Default: false

    noSearch Boolean Deprecated. Flag that indicates whether to hide search.

    Default: false

    fulfillmentAutomationLevel String The level of fulfillment automation for requests.
    Valid values:
    • unspecified: Automation level of item is not specified.
    • manual: Catalog item is not automated.
    • semiAutomated: Catalog item is semi-automated.
    • fullyAutomated: Catalog item is completely automated.
    fulfillmentGroup Reference or String The variable identifier or sys_id of the group [sys_user_group] responsible for delivering the item.
    assignedTopics Array A list of sys_ids of existing taxonomy topics that control the visibility of the item in the Employee Center portal. For more information, see Associate a catalog item with a taxonomy topic in Employee Center.
    Remarque :
    This property is available only when the Employee Experience Taxonomy plugin (sn_ect) is active.
    availableFor Array A list of sys_ids of user criteria records [catalog_item_user_criteria_mtom] that define who can access the item.
    notAvailableFor Array A list of sys_ids of user criteria records [catalog_item_user_criteria_no_mtom] that define who cannot access the item. This property overrides the availableFor property.
    variableSets Array A list of variable identifier VariableSet objects or sys_ids of variable sets [item_option_new_set] to attach to the item. For more information, see VariableSet object.

    Format: { variableSet, order }

    catalogs Array A list of sys_ids of the catalogs [sc_catalog] in which the item appears.
    categories Array A list of sys_ids of the categories [sc_category] to which the item belongs. A catalog must be specified in the catalogs property before categories can be assigned.

    In the Service Portal, catalog searches find only items that are assigned to a category. In Employee Center, catalog searches find only items that are associated with a taxonomy topic. For more information, see Associate a catalog item with a taxonomy topic in Employee Center.

    cost Number A number indicating the one-time cost of the item.

    Default: 0

    displayPriceProperty String The system property that controls how the item price is displayed.
    ignorePrice Boolean Flag that indicates whether to hide the item price in the cart and in the catalog listing.

    Default: true

    mobileHidePrice Boolean Flag that indicates whether to hide the item price on mobile devices.

    Default: false

    omitPrice Boolean Flag that indicates whether to omit the price entirely from all views of the item.

    Default: false

    billable Boolean Flag that indicates whether the item is billable.

    Default: false

    pricingDetails Array A list of pricing entries for the item.
    Valid values:
    • price: A one-time price for the item.
    • recurring_price: A price that recurs at a regular interval. When using this value, the recurringFrequency property is required.

    Format: { amount, currencyType, field }

    recurringFrequency String The time interval at which the recurring price repeats, such as monthly or yearly.

    This property is required when pricingDetails contains a recurring_price field entry.

    requestMethod String The label for the submission button and the order submission experience.
    Valid values:
    • order: Displays an Order Now button. A confirmation dialog is shown and delivery information is editable.
    • request: Displays a Request button. A confirmation dialog is shown but delivery information is not displayed. Use for scenarios where delivery information is pre-determined, such as a code access request.
    • submit: Displays a Submit button. No confirmation dialog or delivery information is displayed. Use for scenarios where no further request information is required, such as a password reset.

    Default: order

    customCart Reference or String The variable identifier or sys_id of a custom UI macro to use for cart rendering. To define a custom cart, use the Record API - ServiceNow Fluent.
    useScLayout Boolean Flag that indicates whether the item uses the Service Catalog layout for display.

    Default: true

    $meta Object Metadata for the application metadata.
    With the installMethod property, you can map the application metadata to an output directory that loads only in specific circumstances.
    $meta: {
          installMethod: 'String'
    }
    Valid values for installMethod:
    • demo: Outputs the application metadata to the metadata/unload.demo directory to be installed with the application when the Load demo data option is selected.
    • first install: Outputs the application metadata to the metadata/unload directory to be installed only the first time an application is installed on an instance.
    import { CatalogItem } from "@servicenow/sdk/core";
    
    export const softwareLicenseRequest = CatalogItem({
      $id: Now.ID["software_license_request"],
      name: "Software License Request",
      shortDescription: "Request a software license",
    
      catalogs: [serviceCatalog],
      categories: [softwareCategory],
    
      // Attach reusable variable sets
      variableSets: [
        { variableSet: contactInfoSet, order: 100 },
        { variableSet: approvalInfoSet, order: 200 }
      ],
    
      // Item-specific variables
      variables: {
        software_name: SingleLineTextVariable({
          question: "Software Name",
          mandatory: true,
          order: 100
        }),
        license_type: SelectBoxVariable({
          question: "License Type",
          choices: {
            individual: { label: "Individual", sequence: 1 },
            team: { label: "Team (5 seats)", sequence: 2 },
            enterprise: { label: "Enterprise (unlimited)", sequence: 3 }
          },
          mandatory: true,
          order: 200
        }),
        number_of_licenses: SingleLineTextVariable({
          question: "Number of Licenses",
          defaultValue: "1",
          order: 300
        }),
        justification: MultiLineTextVariable({
          question: "Business Justification",
          mandatory: true,
          order: 400
        })
      },
    
      // Pricing with recurring charges
      pricingDetails: [
        { amount: 0, currencyType: "USD", field: "price" },
        { amount: 99, currencyType: "USD", field: "recurring_price" }
      ],
      recurringFrequency: "monthly",
    
      flow: "523da512c611228900811a37c97c2014",
      deliveryTime: { days: 3, hours: 0 }
    })

    CatalogItemRecordProducer object

    Create a record producer [sc_cat_item_producer] for users to create task-based records, such as incident or change request records, from the service catalog.

    You can create a record producer for tables and database views that are in the same scope as the record producer. You can also create a record producer for tables that allow create access from applications in other scopes.

    Tableau 2. Properties
    Name Type Description
    $id String or Number Required. A unique ID for the metadata object. When you build the application, this ID is hashed into a unique sys_id. For more information, see ServiceNow Fluent language constructs.

    Format: Now.ID['String' or Number]

    table Reference or String Required. The variable identifier of a Table object or name of a table in which the record producer creates records, such as incident or change_request.
    name String Required. A name for the item that appears in the catalog.
    active Boolean Flag that indicates whether the record producer is active and available to be ordered.

    Default: true

    availability String The type of device on which the item displays.
    Valid values:
    • desktopOnly: The item displays only on desktop devices.
    • mobileOnly: The item displays only on mobile devices.
    • both: The item displays on both desktop and mobile devices.

    Default: desktopOnly

    checkedOut Boolean Flag that indicates whether the item is checked out for editing.

    Default: false

    description String A detailed description of the item that displays in the catalog when a user selects the item or clicks the associated Preview link.

    You can embed videos, images, links to internal knowledge base (KB) articles, and links to external sources of information and instruction documentation.

    meta Array A list of metadata tags used to aid in searches related to the item.
    Remarque :
    The meta property is used only for Zing text indexing and search engine and not for AI Search.
    model Reference or String The variable identifier or sys_id of a product model [cmdb_model] associated with the item. To define a product model, use the Record API - ServiceNow Fluent.
    order Number The order in which the item appears within its category.

    Default: 0

    owner Reference or String The variable identifier or sys_id of a user [sys_user] who owns the item and has edit access to it​. To define a user, use the Record API - ServiceNow Fluent.
    roles Array A list of variable identifiers or sys_ids of roles [sys_user_role] that can access the item.​ To define a role, use the Role API - ServiceNow Fluent.
    shortDescription String A short description of the item that appears on the service catalog homepage, search results, and the title bar of the order form.
    showVariableHelpOnLoad Boolean Flag that indicates whether the item displays variable help text by default.

    Default: false

    startClosed Boolean Flag that indicates whether to starts the item in a collapsed state.

    Default: false

    state String The publication state of the item, such as draft or published.
    variables Object The variable definitions for the item that provide options for requesting it. Each variable type has a specific function. For example:
    variables: {
        laptopType: SelectBoxVariable({
          question: "Laptop Type",
          choices: {
            standard: { label: "Standard Laptop", sequence: 1 },
            developer: { label: "Developer Workstation", sequence: 2 }
          },
          mandatory: true,
          order: 100
        }),
        justification: MultiLineTextVariable({
          question: "Business Justification",
          mandatory: true,
          order: 200
        })
    }

    For general information about catalog, see Service catalog variables.

    version Number A version of the item.

    Default: 1

    view Reference or String Required. The variable identifier or name of the UI view [sys_ui_view] which applies, or the default view.

    To define a UI view, use the Record API - ServiceNow Fluent.

    To use the default view (default_view), you must import it:
    import { default_view } from '@servicenow/sdk/core'
    image String Deprecated. An image for the item.
    icon String An image file that displays as an icon beside the item name in the catalog.

    Use a 27x27 pixel image. If no image is uploaded, the default icon appears.

    picture String An image file to display as a picture of the item.
    mobilePicture String An image to display as a picture of the item on mobile devices.

    This property applies only if the value of the mobilePictureType is mobilePicture.

    mobilePictureType String The type of picture to display for the item on mobile devices.
    Valid values:
    • desktopPicture: Use the image from the picture property.
    • mobilePicture: Use the image from the mobilePicture property.
    • noPicture: The item doesn't display a picture on mobile devices.

    Default: desktopPicture

    assignedTopics Array A list of sys_ids of existing taxonomy topics that control the visibility of the item in the Employee Center portal. For more information, see Associate a catalog item with a taxonomy topic in Employee Center.
    Remarque :
    This property is available only when the Employee Experience Taxonomy plugin (sn_ect) is active.
    availableFor Array A list of sys_ids of user criteria records [catalog_item_user_criteria_mtom] that define who can access the item.
    notAvailableFor Array A list of sys_ids of user criteria records [catalog_item_user_criteria_no_mtom] that define who cannot access the item. This property overrides the availableFor property.
    variableSets Array A list of variable identifier VariableSet objects or sys_ids of variable sets [item_option_new_set] to attach to the item. For more information, see VariableSet object.

    Format: { variableSet, order }

    hideAddToCart Boolean Flag that indicates whether to hide the Add to Cart button.

    Default: false

    hideAddToWishList Boolean Flag that indicates whether to hide the Add to Wishlist button.

    Default: false

    hideDeliveryTime Boolean Flag that indicates whether to hide the delivery time.

    Default: false

    hideQuantitySelector Boolean Flag that indicates whether to hide the Quantity field.

    Default: false

    hideSaveAsDraft Boolean Flag that indicates whether to hide the Save as Draft button.

    Default: false

    hideSP Boolean Flag that indicates whether to hide an item on Service Portal.

    Default: false

    mandatoryAttachment Boolean Flag that indicates whether to require adding an attachment to submit a request.

    Default: false

    hideAttachment Boolean Flag that indicates whether to hide the attachment section and not support adding attachments.

    Default: false

    allowEdit Boolean Flag that indicates whether users can edit the created record after submission.

    Default: false

    canCancel Boolean Flag that indicates whether to display a Cancel button on the record producer form. Users can click Cancel to cancel the record producer and return to the last-viewed screen.

    Default: false

    postInsertScript Script A server-side script that runs after the record is inserted in the associated table. You can call current.update() in this script.
    Remarque :
    This script overrides the target record values and record producer template values.

    This property supports inline JavaScript or a reference to another file in the application that contains a script.

    Format:
    • To use text content from another file, refer to a file in the application using the following format: Now.include('path/to/file'). For more information, see ServiceNow Fluent language constructs.
    • To provide an inline script, use string literals or template literals for multiple lines of code: 'Script' or `Script`.
    Default:
    /**
    * This script is executed after the record is generated. 
    * `current` Is the GlideRecord produced by Record Producer. Use `current.update()` to update the record
    * To access the variables, use `producer.var1` where var1 is the name of the variable
    * To access the Record Producer use `cat_item`
    */
    redirectUrl String The redirect destination after the record is generated.
    Valid values:
    • generatedRecord: Redirects to the task record created by the record producer.
    • catalogHomePage: Redirects to the service catalog.

    Default: generatedRecord

    saveOptions String Advanced configuration options for saving the record producer.
    saveScript Script A script that runs at every step save in Catalog Builder. This property supports inline JavaScript or a reference to another file in the application that contains a script.
    Format:
    • To use text content from another file, refer to a file in the application using the following format: Now.include('path/to/file'). For more information, see ServiceNow Fluent language constructs.
    • To provide an inline script, use string literals or template literals for multiple lines of code: 'Script' or `Script`.
    Default:
    /**
    * This script is executed at every step save in Catalog Builder. 
    * This script is executed before `Script` is executed.
    * `current` Is the GlideRecord produced by Record Producer. 
    * To access the variables, use `producer.var1` where var1 is the name of the variable
    * To access the Record Producer use `cat_item`
    */
    script Script A server-side script that runs before the record is created. Use this script to dynamically assign values to fields on the record. Don't call current.update() or current.insert() in this script.

    This property supports inline JavaScript or a reference to another file in the application that contains a script.

    Format:
    • To use text content from another file, refer to a file in the application using the following format: Now.include('path/to/file'). For more information, see ServiceNow Fluent language constructs.
    • To provide an inline script, use string literals or template literals for multiple lines of code: 'Script' or `Script`.
    Default:
    /** This script is executed before the Record is generated
    * `current`- GlideRecord produced by Record Producer
    * Don't use `current.update()` or `current.insert()` as the record is generated by Record Producer
    * Don't use `current.setValue('sys_class_name', 'xxx')` as this will trigger reparent flow and can cause data loss
    * Avoid `current.setAbortAction()` and generate a separate record
    * Use `producer.var1` to access variables
    */
    $meta Object Metadata for the application metadata.
    With the installMethod property, you can map the application metadata to an output directory that loads only in specific circumstances.
    $meta: {
          installMethod: 'String'
    }
    Valid values for installMethod:
    • demo: Outputs the application metadata to the metadata/unload.demo directory to be installed with the application when the Load demo data option is selected.
    • first install: Outputs the application metadata to the metadata/unload directory to be installed only the first time an application is installed on an instance.
    import { CatalogItemRecordProducer } from "@servicenow/sdk/core";
    
    const serviceCatalog = "e0d08b13c3330100c8b837659bba8fb4";
    const itServicesCategory = "d258b953c611227a0146101fb1be7c31";
    
    export const comprehensiveIncidentProducer = CatalogItemRecordProducer({
      $id: Now.ID["comprehensive_incident_producer"],
      name: "Report Incident with Full Configuration",
      shortDescription: "Complete incident producer with variables and scripts",
      table: "incident",
    
      catalogs: [serviceCatalog],
      categories: [itServicesCategory],
    
      variables: {
        short_description: SingleLineTextVariable({
          question: "Brief Summary",
          mandatory: true,
          mapToField: true,
          field: "short_description",
          order: 100
        }),
        urgency: SelectBoxVariable({
          question: "Urgency",
          mandatory: true,
          mapToField: true,
          field: "urgency",
          choices: {
            "1": { label: "High", sequence: 1 },
            "2": { label: "Medium", sequence: 2 },
            "3": { label: "Low", sequence: 3 }
          },
          order: 200
        }),
        assignment_group: ReferenceVariable({
          question: "Assignment Group",
          mapToField: true,
          field: "assignment_group",
          referenceTable: "sys_user_group",
          order: 300
        })
      },
    
      script: Now.include("../../scripts/rp-pre-insert.js"),
      postInsertScript: Now.include("../../scripts/rp-post-insert.js"),
    
      redirectUrl: "generatedRecord",
      view: "ess",
      allowEdit: true
    })

    CatalogUiPolicy object

    Configure a catalog UI policy [catalog_ui_policy] to dynamically control variable behavior on catalog item forms based on conditions.

    Catalog UI policies can make variables mandatory, read-only, visible, or hidden when specified conditions are met. Use catalog UI policies for simple show/hide, mandatory, and read-only logic. For validation, calculations, or asynchronous calls, use catalog client scripts instead.

    Tableau 3. Properties
    Name Type Description
    $id String or Number Required. A unique ID for the metadata object. When you build the application, this ID is hashed into a unique sys_id. For more information, see ServiceNow Fluent language constructs.

    Format: Now.ID['String' or Number]

    shortDescription String Required. A short description of what the catalog UI policy does.
    catalogItem Reference or String Required only if the variableSet property is not used.The variable identifier or sys_id of the catalog item [sc_cat_item] to which the UI policy applies. For more information, see CatalogItem object.
    variableSet Reference or String Required only if the catalogItem property is not used. The variable identifier or sys_id of the variable set [item_option_new_set] to which the UI policy applies. For more information, see VariableSet object.
    appliesTo String The scope to which the UI policy applies.
    Valid values:
    • item: The policy applies to a catalog item.
    • set: The policy applies to a variable set.

    Default: item

    active Boolean Flag that indicates whether the catalog UI policy is active.

    Default: true

    global Boolean Flag that indicates on which views of the table the Catalog UI Policy runs.

    Default: true

    onLoad Boolean Flag that indicates whether the catalog UI policy runs when the form loads. If false, the policy applies only when variable values change.

    Default: true

    reverseIfFalse Boolean Flag that indicates whether to reverse the UI policy actions when the catalog condition evaluates to false.

    Default: true

    inherit Boolean Flag that indicates whether the Catalog UI Policy is inherited.

    Default: false

    isolateScript Boolean Flag that indicates whether the policy scripts run in an isolated scope.

    Default: true

    catalogCondition String The encoded query conditions based on catalog item variable values that trigger the UI policy. For example:
    catalogCondition: `${catalogItem.variables.singleLineText}=catalogitem^${catalogItem.variables.reference}ISNOTEMPTY^EQ`
    appliesOnCatalogItemView Boolean Flag that indicates whether the UI policy applies to catalog items displayed in the order screen. This view is available to requesters.

    Default: true

    appliesOnTargetRecord Boolean Flag that indicates whether the UI policy applies to records created for task-extended tables via record producers.

    Default: false

    appliesOnCatalogTasks Boolean Flag that indicates whether the UI policy applies to catalog task forms. This view is available to fulfillers.

    Default: false

    appliesOnRequestedItems Boolean Flag that indicates whether the UI policy applies to requested item forms. This view is available to fulfillers.

    Default: false

    runScripts Boolean Flag that indicates whether to run the executeIfTrue and executeIfFalse scripts for this UI policy. Use scripts to apply behaviors beyond read-only, mandatory, or visible, such as targeting a specific role.

    Default: false

    executeIfTrue String A client-side script that runs when the catalog condition evaluates to true. The script must be wrapped in a function onCondition() {} function.
    executeIfFalse String A client-side script that runs when the catalog condition evaluates to false. The script must be wrapped in a function onCondition() {} function.
    runScriptsInUiType String The UI type on which the policy scripts run.
    Valid values:
    • desktop: Scripts run on the desktop interface.
    • mobileOrServicePortal: Scripts run on the mobile and Service Portal interfaces.
    • all: Scripts run on all interfaces.

    Default: desktop

    vaSupported Boolean Flag that indicates whether the UI policy is supported in Virtual Agent conversations.

    Default: false

    actions Array A list of variable actions to perform when the catalog condition is met. For more information, see actions array.
    $meta Object Metadata for the application metadata.
    With the installMethod property, you can map the application metadata to an output directory that loads only in specific circumstances.
    $meta: {
          installMethod: 'String'
    }
    Valid values for installMethod:
    • demo: Outputs the application metadata to the metadata/unload.demo directory to be installed with the application when the Load demo data option is selected.
    • first install: Outputs the application metadata to the metadata/unload directory to be installed only the first time an application is installed on an instance.
    import { CatalogUiPolicy } from "@servicenow/sdk/core";
    import { hardwareRequestItem } from "./catalog-items/HardwareRequest.now";
    
    export const managerApprovalPolicy = CatalogUiPolicy({
      $id: Now.ID["manager_approval_policy"],
      shortDescription: "Show manager approval when high priority selected",
      catalogItem: hardwareRequestItem,
      catalogCondition: `${hardwareRequestItem.variables.priority}=high^EQ`,
      actions: [
        {
          variableName: hardwareRequestItem.variables.manager_approval,
          visible: true,
          mandatory: true
        }
      ]
    })

    actions array

    Configure the variable actions [catalog_ui_policy_action] that a catalog UI policy performs on variables when its conditions are met.

    Each action in the array specifies a variable and the property changes to apply to that variable when the UI policy condition evaluates to true.

    Tableau 4. Properties
    Name Type Description
    variableName String Required. The variable to which the action applies.
    visible Boolean Flag that indicates whether to make the variable visible.

    Default: false

    disabled Boolean Flag that indicates whether to turn off the variable.

    Default: false

    mandatory Boolean Flag that indicates whether to make the variable mandatory.

    Default: false

    cleared Boolean Flag that indicates whether to clear the variable value when the condition is met.

    Default: false

    variableMessage String A message to display on the variable when the condition is met.

    This property applies only if the variableMessageType property has a value.

    variableMessageType String The type of field message.
    Valid values:
    • info
    • warning
    • error
    value String The value to set on the variable when the condition is met.

    This property applies only if the valueAction property is set to setValue.

    valueAction String The action to take on the variable value when the condition is met.
    Valid values:
    • setValue: Sets the variable to the value specified in the value property.
    • clearValue: Clears the variable value.
    order Number The order in which the action is evaluated relative to other actions.

    Default: 100

    actions: [
        {
          variableName: laptopRequest.variables.justification,
          mandatory: true,
          variableMessage: "Justification required for urgent requests",
          variableMessageType: "info",
          order: 100
        },
        {
          variableName: laptopRequest.variables.manager_approval,
          visible: true,
          mandatory: true,
          order: 200
        },
        {
          variableName: laptopRequest.variables.delivery_date,
          visible: true,
          order: 300
        }
    ]

    CatalogClientScript object

    Configure a catalog client script [catalog_script_client] that runs on the client side to control the behavior of a catalog item form.

    Use catalog client scripts to validate user input, auto-populate fields, or display alerts on catalog item forms. For simple show/hide, mandatory, and read-only logic, use catalog UI policies instead.

    Tableau 5. Properties
    Name Type Description
    $id String or Number Required. A unique ID for the metadata object. When you build the application, this ID is hashed into a unique sys_id. For more information, see ServiceNow Fluent language constructs.

    Format: Now.ID['String' or Number]

    name String Required. A unique name for the catalog client script.
    script Script The client-side script to run on the catalog item form. This property supports inline JavaScript or a reference to another file in the application that contains a script.
    Format:
    • To use text content from another file, refer to a file in the application using the following format: Now.include('path/to/file'). For more information, see ServiceNow Fluent language constructs.
    • To provide an inline script, use string literals or template literals for multiple lines of code: 'Script' or `Script`.
    type String The event that triggers the client script to run.
    Valid values:
    • onLoad: Runs when the form loads. Use for initial setup such as setting field states, default values, and visibility.
    • onChange: Runs when a specific variable changes. Always include an if (isLoading) return; guard.
    • onSubmit: Runs when the form is submitted. Return false to block submission. Avoid using GlideAjax in this type because of asynchronous issues.
    uiType String The UI type on which the client script runs.
    Valid values:
    • desktop: Applies to the desktop interface.
    • mobileOrServicePortal: Applies to the mobile and Service Portal interfaces.
    • all: Applies to all interfaces.

    Default: desktop

    active Boolean Flag that indicates whether the client script is enabled.

    Default: true

    appliesTo String Required if using the variableSet property. The scope to which the catalog client script applies.
    Valid values:
    • item: The script applies to a catalog item.
    • set: The script applies to a variable set.

    Default: item

    catalogItem Reference or String Required only if the variableSet property is not used.The variable identifier or sys_id of the catalog item [sc_cat_item] to which the UI policy applies. For more information, see CatalogItem object.
    variableSet Reference or String Required only if the catalogItem property is not used. The variable identifier or sys_id of the variable set [item_option_new_set] to which the UI policy applies. For more information, see VariableSet object.
    variableName String Required if the value of the type property is onChange. The name of the catalog variable that triggers the script when its value changes.
    appliesOnCatalogItemView Boolean Flag that indicates whether the client script applies to catalog items displayed in the order screen of the service catalog. This view is available to requesters.

    Default: true

    appliesOnRequestedItems Boolean Flag that indicates whether the client script applies to requested item forms after the item is requested. This view is available to fulfillers.

    Default: false

    appliesOnCatalogTasks Boolean Flag that indicates whether the client script applies to catalog task forms for the item. This view is available to fulfillers.

    Default: false

    appliesOnTargetRecord Boolean Flag that indicates whether the client script applies to records created for task-extended tables via record producers.

    Default: false

    global Boolean Flag that indicates whether the client script runs in the global scope.

    Default: true

    vaSupported Boolean Flag that indicates whether the client script is supported in Virtual Agent conversations.

    Default: false

    publishedRef String The variable identifier or sys_id of the published catalog item that this client script references. For more information, see CatalogItem object.
    $meta Object Metadata for the application metadata.
    With the installMethod property, you can map the application metadata to an output directory that loads only in specific circumstances.
    $meta: {
          installMethod: 'String'
    }
    Valid values for installMethod:
    • demo: Outputs the application metadata to the metadata/unload.demo directory to be installed with the application when the Load demo data option is selected.
    • first install: Outputs the application metadata to the metadata/unload directory to be installed only the first time an application is installed on an instance.
    import { CatalogClientScript } from "@servicenow/sdk/core";
    import { laptopRequest } from "../catalog-items/laptop-request.now";
    
    CatalogClientScript({
      $id: Now.ID["laptop_onload"],
      name: "Laptop Request - OnLoad",
      script: Now.include("../../client/laptop-onload.js"),
      type: "onLoad",
      catalogItem: laptopRequest,
      active: true,
      appliesOnCatalogItemView: true
    });
    The client script is defined in the laptop-onload.js file referenced from the script property. For example:
    function onLoad() {
      // Set initial field states
      g_form.setReadOnly("estimated_cost", true);
      g_form.setValue("estimated_cost", "$0");
      g_form.setMandatory("justification", true);
    }

    VariableSet object

    Create a variable set [item_option_new_set] that groups reusable variables for use across multiple catalog items and record producers.

    Variable sets are reusable collections of variables that can be attached to catalog items and record producers. Catalog UI policies and client scripts can be scoped to a variable set by setting the appliesTo property to set.

    Remarque :
    • Variable sets within a catalog item cannot have the same internal name.
    • Within a catalog item, the name of a variable cannot be the same as the title or internal name of a variable set.
    • Catalog client scripts and catalog UI policy scripts must refer to the internal name of a variable set, not the title or display name.
    Tableau 6. Properties
    Name Type Description
    $id String or Number Required. A unique ID for the metadata object. When you build the application, this ID is hashed into a unique sys_id. For more information, see ServiceNow Fluent language constructs.

    Format: Now.ID['String' or Number]

    title String Required. The display title of the variable set. This title appears only if the the displayTitle property is set to true.
    internalName String The internal name of the variable set used for programmatic access through the g_form API and server-side scripts. If not provided, the internal name is automatically generated from the title property.
    description String A description of the variable set and its intended use.
    type String The type of the variable set.
    Valid values:
    • singleRow: Variables are arranged in a single row.
    • multiRow: Variables are arranged in multiple rows that users can add or remove.

    Default: singleRow

    layout String The column layout for the variable set.
    Valid values:
    • normal: Variables are displayed in a single column.
    • 2down: Variables are displayed in two columns, one side then the other.
    • 2across: Variables are displayed in two columns with alternating sides.

    Default: normal

    order Number The order in which a variable set displays relative to other variable sets on the form.

    Default: 100

    displayTitle Boolean Flag that indicates whether to display a collapsible section header for the variable set. If true, the value of the title property is displayed as a collapsible header.
    Remarque :
    Check box variables are grouped under a default title of Options. To use a custom title, add a Label variable with an order value that places it directly above the check box variables.

    Default: false

    setAttributes String Additional configuration attributes for the variable set as a comma-separated string, such as max_rows=10,collapsible=true. Use the max_rows attribute to set the maximum number of rows for a multi-row variable set.
    Remarque :
    AttachmentVariable, ContainerVariable, HtmlVariable, and CustomVariable types are not supported in multi-row variable sets.
    readRoles Array A list of variable identifiers or sys_ids of roles [sys_user_role] that can view the variable set.​ To define a role, use the Role API - ServiceNow Fluent.
    writeRoles Array A list of variable identifiers or sys_ids of roles [sys_user_role] that can modify variable values in the set. To define a role, use the Role API - ServiceNow Fluent.
    createRoles Array A list of variable identifiers or sys_ids of roles [sys_user_role] that can create new row instances. To define a role, use the Role API - ServiceNow Fluent.

    This property applies only if the value of the type property is multiRow.

    variables Object The variable definitions for the item that provide options for requesting it. Each variable type has a specific function. For example:
    variables: {
        laptopType: SelectBoxVariable({
          question: "Laptop Type",
          choices: {
            standard: { label: "Standard Laptop", sequence: 1 },
            developer: { label: "Developer Workstation", sequence: 2 }
          },
          mandatory: true,
          order: 100
        }),
        justification: MultiLineTextVariable({
          question: "Business Justification",
          mandatory: true,
          order: 200
        })
    }

    For general information about catalog, see Service catalog variables.

    name String An optional name for additional identification of the variable set.
    version Number The version of the variable set.

    Default: 0

    $meta Object Metadata for the application metadata.
    With the installMethod property, you can map the application metadata to an output directory that loads only in specific circumstances.
    $meta: {
          installMethod: 'String'
    }
    Valid values for installMethod:
    • demo: Outputs the application metadata to the metadata/unload.demo directory to be installed with the application when the Load demo data option is selected.
    • first install: Outputs the application metadata to the metadata/unload directory to be installed only the first time an application is installed on an instance.
    import {
      VariableSet,
      EmailVariable,
      SingleLineTextVariable,
      ReferenceVariable
    } from "@servicenow/sdk/core";
    
    export const contactInfoSet = VariableSet({
      $id: Now.ID["contact_info_set"],
      title: "Contact Information",
      description: "Standard contact information fields",
      type: "singleRow",
      layout: "2across",
      order: 100,
      displayTitle: true,
      variables: {
        email: EmailVariable({
          question: "Email Address",
          mandatory: true,
          order: 100
        }),
        phone: SingleLineTextVariable({
          question: "Phone Number",
          mandatory: true,
          order: 200
        }),
        department: ReferenceVariable({
          question: "Department",
          referenceTable: "cmn_department",
          referenceQualCondition: "active=true",
          order: 300
        })
      }
    })