CatalogJS - Scoped

  • Rversion finale: Australia
  • Mis à jour 12 mars 2026
  • 5 minutes de lecture
  • The CatalogJS API provides methods to check and retrieve catalog-specific properties.

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

    CatalogJS - Catalog(GlideRecord now_GR)

    Creates an instance of the catalog class for the specified glide record object.

    Tableau 1. Parameters
    Name Type Description
    now_GR Object Glide Record pointing to the sc_catalog table.

    This example shows how to create a new instance of the catalog class.

    var now_GR = new GlideRecord('sc_catalog');
     now_GR.addQuery('sys_id','e0d08b13c3330100c8b837659bba8fb4');
     now_GR.query();
     var catalog = new sn_sc.Catalog(now_GR);

    CatalogJS - Catalog(String sys_id)

    Creates an instance of the Catalog class with the specified sys_id.

    Tableau 2. Parameters
    Name Type Description
    sys_id String Sys_id of the catalog.

    This example shows how to create an instance of the Catalog class wit the specified syst_id.

    new sn_sc.Catalog(catalog_sys_id);
    var catalog = new sn_sc.Catalog("31bea3d53790200044e0bfc8bcbe5dec");

    CatalogJS - canView(Boolean mobile, String userId)

    Determines whether a user can view the current category on a mobile device or desktop.

    Tableau 3. Parameters
    Name Type Description
    mobile Boolean

    Flag that indicates whether to check if the user can view the current catalog on a mobile view or desktop view.

    Valid values:
    • true: Mobile view
    • false: Desktop view
    userId String Optional. Sys_id of the user to check if they can view the catalog.

    Default: Current user

    Tableau 4. Returns
    Type Description
    Boolean

    Flag that indicates whether the catalog is viewable by the user.

    Valid values:
    • true: Catalog is viewable by the user.
    • false: Catalog is not viewable by the user.

    Example:

    var catalog = new sn_sc.Catalog("e0d08b13c3330100c8b837659bba8fb4");
    gs.info(catalog.canView(true));

    Output:

    true

    CatalogJS - getAvailableCatalog()

    Returns the available active catalog.

    If only one active catalog exists, then the method returns that catalog. Otherwise, it returns the earliest catalog created from the list of the catalogs that the user can view. If no catalog is available, the method returns null.

    Tableau 5. Parameters
    Name Type Description
    None
    Tableau 6. Returns
    Type Description
    Object Object pointing to the earliest catalog that the user can view, or null if no catalog is available.

    This example returns the catalog that is available to the current user.

    var catalog = sn_sc.Catalog.getAvailableCatalog()

    CatalogJS - getBackgroundColor()

    Returns the catalog background color.

    Tableau 7. Parameters
    Name Type Description
    None
    Tableau 8. Returns
    Type Description
    String Background color of the catalog.

    This example returns the background color for the associated catalog.

    var catalog = new sn_sc.Catalog("0f910a2ac3112200b12d9f2974d3ae3c");
    gs.info("Catalog background: " + catalog.getBackgroundColor());

    Output:

    Catalog background: white

    CatalogJS - getCatalogCount()

    Returns the number of catalogs active in the catalog table.

    Tableau 9. Parameters
    Name Type Description
    None
    Tableau 10. Returns
    Type Description
    Integer Number of catalogs available in the catalog table.

    Example:

    console.log(sn_sc.Catalog.getCatalogCount());

    Output:

    3

    CatalogJS - getCategories()

    Returns the categories for the current catalog.

    Tableau 11. Parameters
    Name Type Description
    None
    Tableau 12. Returns
    Type Description
    ArrayList Returns the categories for the current catalog.

    This example returns the categories available in the current catalog object.

    var catalog=new sn_sc.Catalog("e0d08b13c3330100c8b837659bba8fb4");
    console.log(catalog.getCategories());

    Output:

    0 : {header_image: "", sys_id: "e15706fc0a0a0aa7007fc21e1ab70c2f", description: "Your IT gateway. Report issues and submit requests.", title: "Can We Help You?"} 
    1 : {header_image: "", sys_id: "95fc11615f1211001c9b2572f2b477c6", description: "Services offered by different departments in the organization", title: "Departmental Services"} 
    2 : {header_image: "", sys_id: "900682363731300054b6a3549dbe5d5f", description: "Desktop computers for your work area.", title: "Desktops"} 
    3 : {header_image: "", sys_id: "d2f716fcc611227a015a142fa0b262c1", description: "Order new furniture, and fixtures, or request for cubicle modifications can also be ordered here.", title: "Furniture and Decor"} 
    4 : {header_image: "", sys_id: "d258b953c611227a0146101fb1be7c31", description: "Order from a variety of hardware to meet your business needs, including phones, tablets and laptops.", title: "Hardware"} 

    CatalogJS - getCategoryIds()

    Specifies the sys_ids of the categories in the current catalog.

    Tableau 13. Parameters
    Name Type Description
    None
    Tableau 14. Returns
    Type Description
    ArrayList Returns the sys_ids of the categories in the current catalog.

    This example returns the sys_ids of the categories available in the current catalog.

    var catalog=new sn_sc.Catalog("e0d08b13c3330100c8b837659bba8fb4");
    console.log(catalog.getCategoryIds());

    Output:

    0:"e15706fc0a0a0aa7007fc21e1ab70c2f"
    1 : "95fc11615f1211001c9b2572f2b477c6"
    2 : "900682363731300054b6a3549dbe5d5f"
    3 : "d2f716fcc611227a015a142fa0b262c1"

    CatalogJS - getDescription()

    Returns the description of the current catalog.

    Tableau 15. Parameters
    Name Type Description
    None
    Tableau 16. Returns
    Type Description
    String Catalog description.

    This example returns the name of the current catalog.

    var catalog=new sn_sc.Catalog("e0d08b13c3330100c8b837659bba8fb4");
    console.log(catalog.getDescription());

    Output:

    Service Catalog - IT Now

    CatalogJS - getDesktopImageSRC()

    Returns the catalog desktop image file name.

    Tableau 17. Parameters
    Name Type Description
    None
    Tableau 18. Returns
    Type Description
    String Catalog desktop image file name.

    This example returns the current catalog desktop image file name.

    var catalog=new sn_sc.Catalog("e0d08b13c3330100c8b837659bba8fb4");
    console.log(catalog.getDesktopImageSRC());

    Output:

    adbcc271475211002ee987e8dee49001.iix

    CatalogJS - getGr()

    Returns the current catalog's GlideRecord.

    Tableau 19. Parameters
    Name Type Description
    None
    Tableau 20. Returns
    Type Description
    GlideRecord GlideRecord of the current catalog.

    This example returns the GlideRecord for the specified catalog.

    var catalog = new sn_sc.Catalog("e0d08b13c3330100c8b837659bba8fb4");
    data.history = catalog.getGr();

    CatalogJS - getHeaderIconSRC()

    Returns the current catalog's header icon.

    Tableau 21. Parameters
    Name Type Description
    None
    Tableau 22. Returns
    Type Description
    String Catalog header icon.

    This example shows how to obtain the name of the catalog header icon.

    var catalog=new sn_sc.Catalog("e0d08b13c3330100c8b837659bba8fb4");
    gs.info(catalog.getHeaderIconSRC());

    Output:

    service_catalog_header.png

    CatalogJS - getID()

    Returns the sys_id of the current catalog.

    Tableau 23. Parameters
    Name Type Description
    None
    Tableau 24. Returns
    Type Description
    String Sys_id of the current catalog.

    This example returns the sys_id of the current catalog.

    var catalog=new sn_sc.Catalog("e0d08b13c3330100c8b837659bba8fb4");
    console.log(catalog.getId());

    Output:

    e0d08b13c3330100c8b837659bba8fb4

    CatalogJS - getTitle()

    Returns the title of the current catalog.

    Tableau 25. Parameters
    Name Type Description
    None
    Tableau 26. Returns
    Type Description
    String Title of the current catalog.

    This example returns the title of the current catalog.

    var catalog=new sn_sc.Catalog("e0d08b13c3330100c8b837659bba8fb4");
    gs.info(catalog.getTitle());

    Output:

    Service Catalog

    CatalogJS - hasCategories()

    Specifies if the current catalog has categories.

    Tableau 27. Parameters
    Name Type Description
    None
    Tableau 28. Returns
    Type Description
    Boolean

    Flag that indicates whether the current catalog has categories.

    Valid values:
    • true: Catalog has categories.
    • false: Catalog does not have categories.

    This examples shows how to determine if the current catalog contains categories.

    var catalog=new sn_sc.Catalog("e0d08b13c3330100c8b837659bba8fb4");
    gs.info(catalog.hasCategories());

    Output:

    false

    CatalogJS - hasItems()

    Specifies if the current catalog has catalog items.

    Tableau 29. Parameters
    Name Type Description
    None
    Tableau 30. Returns
    Type Description
    Boolean

    Flag that indicates whether the current catalog has catalog items.

    Valid values:
    • true: Catalog has catalog items.
    • false: Catalog does not have catalog items.

    Example:

    var catalog=new sn_sc.Catalog("e0d08b13c3330100c8b837659bba8fb4");
    gs.info(catalog.hasItems());

    Output:

    true

    CatalogJS - isWishlistEnabled()

    Specifies if the wish list is enabled for the current catalog.

    Tableau 31. Parameters
    Name Type Description
    None
    Tableau 32. Returns
    Type Description
    Boolean

    Flag that indicates whether the current catalog supports wish lists.

    Valid values:
    • true: Catalog supports wish lists.
    • false: Catalog does not support wish lists.

    This example shows how to check if a wish lists are enabled for the current catalog.

    var catalog = new sn_sc.Catalog("e0d08b13c3330100c8b837659bba8fb4");
    gs.info(catalog.isWishlistEnabled());
    

    Output:

    true