---
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


---

# CatalogClientScript - Scoped

# CatalogClientScript - Scoped {#ariaid-title1}

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

The CatalogClientScript API provides methods that enable you to create, modify, or delete catalog client script records.

To use this class in a scoped application, use the `sn_sc` namespace identifier.
The Service Catalog Scoped API plugin (ID: com.glideapp.servicecatalog.scoped.api) that is
enabled by default is required to access the CatalogClientScript API.

## CatalogClientScript - CatalogClientScript() {#ariaid-title2}

Creates an instance of the CatalogClientScript class.
{#r_CCSS-CatalogClientScript__table_hlv_q2c_1z__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

{#r_CCSS-CatalogClientScript__table_hlv_q2c_1z}  

    var catalogClientScript = new sn_sc.CatalogClientScript();

## CatalogClientScript - addScript(String script) {#ariaid-title3}

Adds a script to the catalog client script.
{#r_CCSS-addScript_S__table_m1v_1ds_sy__entry__3}

| Name | Type | Description |
|-|-|-|
| script | String | Script to be added to the catalog client script. |
[Table 2. Parameters]

{#r_CCSS-addScript_S__table_m1v_1ds_sy} {#r_CCSS-addScript_S__table_n1v_1ds_sy__entry__2}

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

{#r_CCSS-addScript_S__table_n1v_1ds_sy}  
This example shows how to call this method.

    var catalogClientScript = new sn_sc.CatalogClientScript();
    catalogClientScript.addScript("function onLoad(){Enter the script}");

## CatalogClientScript - appliesToCatalogItem(Boolean flag) {#ariaid-title4}

Specifies if the catalog client script runs on a catalog item.
{#r_CCSS-appliesToCatalogItem_B__table_zsm_rzr_sy__entry__3}

| Name | Type | Description |
|-|-|-|
| flag | Boolean | If true, the catalog client script runs on the catalog item. If false, the catalog client script does not run on the catalog item. |
[Table 4. Parameters]

{#r_CCSS-appliesToCatalogItem_B__table_zsm_rzr_sy} {#r_CCSS-appliesToCatalogItem_B__table_atm_rzr_sy__entry__2}

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

{#r_CCSS-appliesToCatalogItem_B__table_atm_rzr_sy}  

    var catalogClientScript = new sn_sc.CatalogClientScript();
    catalogClientScript.appliesToCatalogItem(true);

## CatalogClientScript - appliesToCatalogTask(Boolean flag) {#ariaid-title5}

Specifies if the catalog client script runs on a catalog task.
{#r_CCSS-appliesToCatalogTask_B__table_tqp_n2s_sy__entry__3}

| Name | Type | Description |
|-|-|-|
| flag | Boolean | If true, the catalog client script runs on the catalog task. If false, the catalog client script does not run on the catalog task. |
[Table 6. Parameters]

{#r_CCSS-appliesToCatalogTask_B__table_tqp_n2s_sy} {#r_CCSS-appliesToCatalogTask_B__table_uqp_n2s_sy__entry__2}

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

{#r_CCSS-appliesToCatalogTask_B__table_uqp_n2s_sy}  
This example shows how to call this method.

    var catalogClientScript = new sn_sc.CatalogClientScript();
    catalogClientScript.appliesToCatalogTask(true);

## CatalogClientScript - appliesToRequestedItem(Boolean flag) {#ariaid-title6}

Specifies if the catalog client script runs on a requested item.
{#r_CCSS-appliesToRequestedItem_B__table_rsq_p1s_sy__entry__3}

| Name | Type | Description |
|-|-|-|
| flag | Boolean | If true, the catalog client script runs on the requested item. If false, the catalog client script does not run on the requested item. |
[Table 8. Parameters]

{#r_CCSS-appliesToRequestedItem_B__table_rsq_p1s_sy} {#r_CCSS-appliesToRequestedItem_B__table_ssq_p1s_sy__entry__2}

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

{#r_CCSS-appliesToRequestedItem_B__table_ssq_p1s_sy}  
This example shows how to call the method.

    var catalogClientScript = new sn_sc.CatalogClientScript();
    catalogClientScript.appliesToRequestedItem(true);

## CatalogClientScript - appliesToTargetRecord(Boolean flag) {#ariaid-title7}

Specifies if the catalog client script runs on a requested item.
{#r_CCSS-appliesToTargetRecord_B__table_hwy_44l_5z__entry__3}

| Name | Type | Description |
|-|-|-|
| flag | Boolean | If true, the catalog client script runs on the target record. If false, the catalog client script does not run on the target record. |
[Table 10. Parameters]

{#r_CCSS-appliesToTargetRecord_B__table_hwy_44l_5z} {#r_CCSS-appliesToTargetRecord_B__table_iwy_44l_5z__entry__2}

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

{#r_CCSS-appliesToTargetRecord_B__table_iwy_44l_5z}  
This example shows how to call the method.

    var catalogClientScript = new sn_sc.CatalogClientScript();
    catalogClientScript.appliesToTargetRecord(true);

## CatalogClientScript - create(Boolean standardUpdate) {#ariaid-title8}

Inserts the defined catalog client script in the catalog_script_client table.
{#r_CCSS-create_B__table_kj1_xbs_kx__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_CCSS-create_B__ul_nnx_xwn_kpb} |
[Table 12. Parameters]

{#r_CCSS-create_B__table_kj1_xbs_kx} {#r_CCSS-create_B__table_lj1_xbs_kx__entry__2}

| Type | Description |
|-|-|
| String | Sys_id of the catalog client script. |
[Table 13. Returns]

{#r_CCSS-create_B__table_lj1_xbs_kx}  
This example shows how to call the method.

    var catalogClientScript = new sn_sc.CatalogClientScript();
    catalogClientScript.setAttributes({"name": "My Catalog Item", "applies_to": "item", "ui_type": "desktop", "type": "onLoad"});
    catalogClientScript.appliesToCatalogItem(true);
    catalogClientScript.appliesToRequestedItem(true);
    catalogClientScript.appliesToCatalogTask(true);
    catalogClientScript.appliesToTargetRecord(true);
    var catalogClientScriptId = catalogClientScript.create();
    gs.info(catalogClientScriptId);

Output:

    039c516237b1300054b6a3549dbe5dfc

## CatalogClientScript - deleteRecord(String sys_id, Boolean standardUpdate) {#ariaid-title9}

Deletes the defined catalog client script.
{#r_CCSS-deleteRecord_S_B__table_jdv_hsz_qy__entry__3}

| Name | Type | Description |
|-|-|-|
| sys_id | String | Sys_id of the catalog client script. |
| 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_CCSS-deleteRecord_S_B__ul_nnx_xwn_kpb} |
[Table 14. Parameters]

{#r_CCSS-deleteRecord_S_B__table_jdv_hsz_qy} {#r_CCSS-deleteRecord_S_B__table_kdv_hsz_qy__entry__2}

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

{#r_CCSS-deleteRecord_S_B__table_kdv_hsz_qy}  
The following example shows how to delete a catalog client script.

    var sys_id = "039c516237b1300054b6a3549dbe5dfc"; 
    var catalogClientScript = new sn_sc.CatalogClientScript();
    catalogClientScript.deleteRecord("039c516237b1300054b6a3549dbe5dfc");

## CatalogClientScript - setAttributes(Map attributes) {#ariaid-title10}

Defines attribute values for the catalog client script.
{#r_CCSS-setAttributes_M__table_fyy_tyr_sy__entry__3}

| Name | Type | Description |
|-|-|-|
| attributes | Map | A JSON object that has mapping for the field and value pairs. |
[Table 16. Parameters]

{#r_CCSS-setAttributes_M__table_fyy_tyr_sy} {#r_CCSS-setAttributes_M__table_gyy_tyr_sy__entry__2}

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

{#r_CCSS-setAttributes_M__table_gyy_tyr_sy}  
This example shows how to call the method.

    var catalogClientScript = new sn_sc.CatalogClientScript();
    catalogClientScript.setAttributes({"name": "My Catalog Item", "applies_to": "catalog_item", "ui_type": "desktop", "type": "onLoad"});

## CatalogClientScript - setCatalogItem(String sys_id) {#ariaid-title11}

Associates a catalog item with the catalog client script.
{#r_CCSS-setCatalogItem_S__table_v3g_zds_sy__entry__3}

| Name | Type | Description |
|-|-|-|
| sys_id | String | Sys_id of the catalog item. |
[Table 18. Parameters]

{#r_CCSS-setCatalogItem_S__table_v3g_zds_sy} {#r_CCSS-setCatalogItem_S__table_w3g_zds_sy__entry__2}

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

{#r_CCSS-setCatalogItem_S__table_w3g_zds_sy}  
This example shows how to associate a catalog item with the current catalog client
script.

    var catalogClientScript = new sn_sc.CatalogClientScript();
    catalogClientScript.setCatalogItem("039c516237b1300054b6a3549dbe5dfc");

## CatalogClientScript - setOnChangeVariable(String sys_id) {#ariaid-title12}

Runs the catalog client script when a variable value is updated.
{#r_CCSS-setOnChangeVariable_S__table_m3r_3cs_sy__entry__3}

| Name | Type | Description |
|-|-|-|
| sys_id | String | Sys_id of the variable. |
[Table 20. Parameters]

{#r_CCSS-setOnChangeVariable_S__table_m3r_3cs_sy} {#r_CCSS-setOnChangeVariable_S__table_n3r_3cs_sy__entry__2}

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

{#r_CCSS-setOnChangeVariable_S__table_n3r_3cs_sy}  
This example shows how to call the method.

    var catalogClientScript = new sn_sc.CatalogClientScript();
    catalogClientScript.setOnChangeVariable("039c516237b1300054b6a3549dbe5dfc");

## CatalogClientScript - setVariableSet(String sys_id) {#ariaid-title13}

Associates a variable set with the catalog client script.
{#r_CCSS-setVariableSet_S__table_cvz_tbs_sy__entry__3}

| Name | Type | Description |
|-|-|-|
| sys_id | String | Sys_id of the variable set. |
[Table 22. Parameters]

{#r_CCSS-setVariableSet_S__table_cvz_tbs_sy} {#r_CCSS-setVariableSet_S__table_dvz_tbs_sy__entry__2}

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

{#r_CCSS-setVariableSet_S__table_dvz_tbs_sy}  
This example shows how to call the method.

    var catalogClientScript = new sn_sc.CatalogClientScript();
    catalogClientScript.setVariableSet("039c516237b1300054b6a3549dbe5dfc");


