CatalogClientScript - Scoped

CatalogClientScript API enables 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.

Scoped CatalogClientScript - addScript(String script)

Adds a script to the catalog client script.

Table 1. Parameters
Name Type Description
script String Script to be added to the catalog client script.
Table 2. Returns
Type Description
void

Example

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

Scoped CatalogClientScript - appliesToCatalogItem(Boolean flag)

Specifies if the catalog client script runs on a catalog item.

Table 3. Parameters
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. Returns
Type Description
void

Example

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

Scoped CatalogClientScript - appliesToCatalogTask(Boolean flag)

Specifies if the catalog client script runs on a catalog task.

Table 5. Parameters
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. Returns
Type Description
void

Example

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

Scoped CatalogClientScript - appliesToRequestedItem(Boolean flag)

Specifies if the catalog client script runs on a requested item.

Table 7. Parameters
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. Returns
Type Description
void

Example

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

Scoped CatalogClientScript - CatalogClientScript()

Creates an instance of the CatalogClientScript class.

Table 9. Parameters
Name Type Description
None
var catalogClientScript = new sn_sc.CatalogClientScript();

Scoped CatalogClientScript - create(Boolean standardUpdate)

Inserts the defined catalog client script in the catalog_script_client table.

Table 10. Parameters
Name Type Description
standardUpdate Boolean Set to true to enable the running of engines and workflow.
Table 11. Returns
Type Description
String sys_id of the catalog client script.

Example

        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);
        var catalogClientScriptId = catalogClientScript.create();
        gs.info(catalogClientScriptId);
      
      
      
      

Output

039c516237b1300054b6a3549dbe5dfc

Scoped CatalogClientScript - deleteRecord(String sys_id, Boolean standardUpdate)

Deletes the defined catalog client script.

Table 12. Parameters
Name Type Description
sys_id String sys_id of the catalog client script.
standardUpdate Boolean Set to true to enable the running of engines and workflow.
Table 13. Returns
Type Description
void

Example

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

Scoped CatalogClientScript - setAttributes(Map attributes)

Defines attribute values for the catalog client script.

Table 14. Parameters
Name Type Description
attributes Map A JSON object that has mapping for the field and value pairs.
Table 15. Returns
Type Description
void

Example

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

Scoped CatalogClientScript - setCatalogItem(String sys_id)

Associates a catalog item with the catalog client script.

Table 16. Parameters
Name Type Description
sys_id String sys_id of the catalog item.
Table 17. Returns
Type Description
void

Example

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

Scoped CatalogClientScript - setOnChangeVariable(String sys_id)

Runs the catalog client script when a variable value is updated.

Table 18. Parameters
Name Type Description
sys_id String sys_id of the variable.
Table 19. Returns
Type Description
void

Example

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

Scoped CatalogClientScript - setVariableSet(String sys_id)

Associates a variable set with the catalog client script.

Table 20. Parameters
Name Type Description
sys_id String sys_id of the variable set.
Table 21. Returns
Type Description
void

Example

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