---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# CatalogItemVariableSet - Scoped

# CatalogItemVariableSet - Scoped {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read

The CatalogItemVariableSet API provides methods that enable you to create and modify service catalog item variable sets using scripts.

This API runs in the `sn_sc` namespace.

## CatalogItemVariableSet - create(Boolean standardUpdate) {#ariaid-title2}

Inserts the defined catalog item variable set.
{#r_CatalogItemVariableSet-create_Boolean__table_dk2_55d_ns__entry__3}

| Name | Type | Description |
|-|-|-|
| standardUpdate | Boolean | Flag indicating whether to enable the running of engines and workflow. Valid values: * true: Enable the running of engines and workflow. * false: Do not enable the running of engines and workflow. {#r_CatalogItemVariableSet-create_Boolean__ul_ygw_ztp_lnb} |
[Table 1. Parameters]

{#r_CatalogItemVariableSet-create_Boolean__table_dk2_55d_ns} {#r_CatalogItemVariableSet-create_Boolean__table_ek2_55d_ns__entry__2}

| Type | Description |
|-|-|
| String | Sys_id of the inserted variable record. |
[Table 2. Returns]

{#r_CatalogItemVariableSet-create_Boolean__table_ek2_55d_ns}  

    // Given an existing catalog item
    var catItemSysId = "e0d08b13c3330100c8b837659bba8fb4";
    addVariableSets(catItemSysId);

    function addVariableSets(catItemSysId) {
      // List of all variable sets to attach
      var myVarSets = [];

      // Create variable set
      var myVarSetAttrs = {"name": "Requester details", "order": "100"};
      var myVarSet = new sn_sc.CatalogItemVariableSet();
      myVarSet.setAttributes(myVarSetAttrs);
      var myVarSetId = myVarSet.create(true);
      myVarSets.push(myVarSetId);
    }

## CatalogItemVariableSet - deleteRecord(Boolean standardUpdate) {#ariaid-title3}

Deletes a variable set.
{#r_CatalogItemVariableSet-deleteRecord_Boolean__table_rzk_z5d_ns__entry__3}

| Name | Type | Description |
|-|-|-|
| standardUpdate | Boolean | Flag that indicates whether to enable the running of engines and workflow. Valid values: * true: Enable engines and workflow. * false: Do not enable engines and workflow. {#r_CatalogItemVariableSet-deleteRecord_Boolean__ul_nnx_xwn_kpb} |
[Table 3. Parameters]

{#r_CatalogItemVariableSet-deleteRecord_Boolean__table_rzk_z5d_ns} {#r_CatalogItemVariableSet-deleteRecord_Boolean__table_szk_z5d_ns__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 4. Returns]

{#r_CatalogItemVariableSet-deleteRecord_Boolean__table_szk_z5d_ns}  
This example removes My Variable Set from all catalog items that use it, and then deletes
My Variable Set.

    // Get the sys_id of the variable set you want to delete
    var vSet = new GlideRecord('item_option_new_set');
    vSet.addEncodedQuery('title=My Variable Set'); // find My Variable Set
    vSet.query();
    if (vSet.next()) {

        // first remove the variable set from all catalog items
        var catItemVset = new GlideRecord('io_set_item'); // M2M table linking variable set and catalog item
        catItemVset.addQuery('variable_set', vSet.getUniqueValue); // find all catalog items using My Variable Set
        catItemVset.query();
        while (catItemVset.next()) {
            var vsetM2M = new sn_sc.CatalogItemVariableSetM2M(catItemVset.getUniqueValue()); // io_set_item M2M record sys_id
            vsetM2M.deleteRecord(true); // delete M2M record
        }

        // then delete the variable set record
        var varset = new sn_sc.CatalogItemVariableSet(vSet.getUniqueValue()); 
        varset.deleteRecord(true);
    }

## CatalogItemVariableSet - read(Object columns, Boolean standardUpdate) {#ariaid-title4}

Returns a mapping of catalog item variable set attribute values.
{#r_CatalogItemVariableSet-read_Object_Boolean__table_k4p_dvd_ns__entry__3}

| Name | Type | Description |
|-|-|-|
| columns | Object | Specify the set of columns that you would like the values for. |
| standardUpdate | Boolean | Flag that indicates whether to enable the running of engines and workflow. Valid values: * true: Enable engines and workflow. * false: Do not enable engines and workflow. {#r_CatalogItemVariableSet-read_Object_Boolean__ul_nnx_xwn_kpb} |
[Table 5. Parameters]

{#r_CatalogItemVariableSet-read_Object_Boolean__table_k4p_dvd_ns} {#r_CatalogItemVariableSet-read_Object_Boolean__table_l4p_dvd_ns__entry__2}

| Type | Description |
|-|-|
| Object | An object mapping column names to values. |
[Table 6. Returns]

{#r_CatalogItemVariableSet-read_Object_Boolean__table_l4p_dvd_ns}

## CatalogItemVariableSet - setAttributes(Object attributes) {#ariaid-title5}

Sets attributes for a variable set.
{#r_CatalogItemVariableSet-setAttributes_Map__table_urd_nvd_ns__entry__3}

| Name | Type | Description |
|-|-|-|
| attributes | Object | An object mapping column names to values. |
[Table 7. Parameters]

{#r_CatalogItemVariableSet-setAttributes_Map__table_urd_nvd_ns} {#r_CatalogItemVariableSet-setAttributes_Map__table_vrd_nvd_ns__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 8. Returns]

{#r_CatalogItemVariableSet-setAttributes_Map__table_vrd_nvd_ns}  
This example creates a variable set and then adds a variable to the new set.

    createVariableSet('My Variable Set', 'This is my test variable set', '100', 'one_to_one');

    function createVariableSet(name, description, order, type) {
        var myVarSet = new sn_sc.CatalogItemVariableSet();
        // fields used in object are from table item_option_new_set
        var myVarSetAttrs = {
            "name": name,
            "description": description,
            "order": order,
            "type": type
        }; 
        myVarSet.setAttributes(myVarSetAttrs);
        var myVarSetId = myVarSet.create(true); // returns the sys_id of the created variable set
        gs.info('Variable set created in table item_option_new_set with sys_id ' + myVarSetId);

        // add a variable to the newly created variable set
        var myVar = new sn_sc.CatalogItemVariable();
        var myVarAttrs = {
            "type": "6", // type 6 is single line text
            "variable_set": myVarSetId.toString(), 
            "question_text": "Example question",
            "name": "example_question",
            "order": 200
        };
        myVar.setAttributes(myVarAttrs);
        myVar.create(true);
    }

Output:

    Variable set created in table item_option_new_set with sys_id e21df65a1bff7c10593876a61a4bcbc4

## CatalogItemVariableSet - update(Object columnValues, Boolean standardUpdate) {#ariaid-title6}

Updates a variable set.
{#r_CatalogItemVariableSet-update_Object_Boolean__table_z35_5vd_ns__entry__3}

| Name | Type | Description |
|-|-|-|
| columnValues | Object | An object mapping column names to values. |
| standardUpdate | Boolean | Flag that indicates whether to enable the running of engines and workflow. Valid values: * true: Enable engines and workflow. * false: Do not enable engines and workflow. {#r_CatalogItemVariableSet-update_Object_Boolean__ul_nnx_xwn_kpb} |
[Table 9. Parameters]

{#r_CatalogItemVariableSet-update_Object_Boolean__table_z35_5vd_ns} {#r_CatalogItemVariableSet-update_Object_Boolean__table_aj5_5vd_ns__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 10. Returns]

{#r_CatalogItemVariableSet-update_Object_Boolean__table_aj5_5vd_ns}  
This example updates the description and order for the Standard Employee Questions variable
set.

    // Get the sys_id of the variable set you want to update
    var vSet = new GlideRecord('item_option_new_set');
    vSet.addEncodedQuery('title=Standard Employee Questions'); // find the Standard Employee Questions variable set
    vSet.query();
    if (vSet.next()) {
        var varset = new sn_sc.CatalogItemVariableSet(vSet.getUniqueValue()); 
        var attr = {
            'description': 'This should be used for all end user requests such as phones, tablets, etc. \n My description line',
            'order': '500' 
        };
        varset.update(attr, true);
    }


