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


---

# CatalogJS - Scoped

# CatalogJS - Scoped {#ariaid-title1}

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

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) {#ariaid-title2}

Creates an instance of the catalog class for the specified glide record
object.
{#CJS-Catalog_G__table_og2_g1c_5bb__entry__3}

| Name | Type | Description |
|-|-|-|
| now_GR | Object | Glide Record pointing to the sc_catalog table. |
[Table 1. Parameters]

{#CJS-Catalog_G__table_og2_g1c_5bb}  
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) {#ariaid-title3}

Creates an instance of the Catalog class with the specified sys_id.
{#CJS-Catalog_S__table_tf1_gbc_5bb__entry__3}

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

{#CJS-Catalog_S__table_tf1_gbc_5bb}  
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) {#ariaid-title4}

Determines whether a user can view the current category on a mobile device or
desktop.
{#CJS-canView_B__table_mnl_2lz_sbb__entry__3}

| 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 {#CJS-canView_B__ul_qfp_cb4_kpb} |
| userId | String | Optional. Sys_id of the user to check if they can view the catalog. Default: Current user |
[Table 3. Parameters]

{#CJS-canView_B__table_mnl_2lz_sbb} {#CJS-canView_B__table_nnl_2lz_sbb__entry__2}

| 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. {#CJS-canView_B__ul_wbn_mb4_kpb} |
[Table 4. Returns]

{#CJS-canView_B__table_nnl_2lz_sbb}  
Example:

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

Output:

    true

## CatalogJS - getAvailableCatalog() {#ariaid-title5}

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.
{#CJS-getAvailableCatalog__table_m31_rmz_sbb__entry__3}

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

{#CJS-getAvailableCatalog__table_m31_rmz_sbb} {#CJS-getAvailableCatalog__table_n31_rmz_sbb__entry__2}

| Type | Description |
|-|-|
| Object | Object pointing to the earliest catalog that the user can view, or null if no catalog is available. |
[Table 6. Returns]

{#CJS-getAvailableCatalog__table_n31_rmz_sbb}  
This example returns the catalog that is available to the current user.

    var catalog = sn_sc.Catalog.getAvailableCatalog()

## CatalogJS - getBackgroundColor() {#ariaid-title6}

Returns the catalog background color.
{#CJS-getBackgroundColor__table_etj_mrz_sbb__entry__3}

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

{#CJS-getBackgroundColor__table_etj_mrz_sbb} {#CJS-getBackgroundColor__table_ftj_mrz_sbb__entry__2}

| Type | Description |
|-|-|
| String | Background color of the catalog. |
[Table 8. Returns]

{#CJS-getBackgroundColor__table_ftj_mrz_sbb}  
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() {#ariaid-title7}

Returns the number of catalogs active in the catalog table.
{#CJS-getCatalogCount__table_ez1_znz_sbb__entry__3}

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

{#CJS-getCatalogCount__table_ez1_znz_sbb} {#CJS-getCatalogCount__table_fz1_znz_sbb__entry__2}

| Type | Description |
|-|-|
| Integer | Number of catalogs available in the catalog table. |
[Table 10. Returns]

{#CJS-getCatalogCount__table_fz1_znz_sbb}  
Example:

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

Output:

    3

## CatalogJS - getCategories() {#ariaid-title8}

Returns the categories for the current catalog.
{#CJS-getCategories__table_nwt_l4z_sbb__entry__3}

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

{#CJS-getCategories__table_nwt_l4z_sbb} {#CJS-getCategories__table_owt_l4z_sbb__entry__2}

| Type | Description |
|-|-|
| ArrayList | Returns the categories for the current catalog. |
[Table 12. Returns]

{#CJS-getCategories__table_owt_l4z_sbb}  
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() {#ariaid-title9}

Specifies the sys_ids of the categories in the current catalog.
{#CJS-getCategoryIds__table_ivv_3pz_sbb__entry__3}

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

{#CJS-getCategoryIds__table_ivv_3pz_sbb} {#CJS-getCategoryIds__table_jvv_3pz_sbb__entry__2}

| Type | Description |
|-|-|
| ArrayList | Returns the sys_ids of the categories in the current catalog. |
[Table 14. Returns]

{#CJS-getCategoryIds__table_jvv_3pz_sbb}  
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() {#ariaid-title10}

Returns the description of the current catalog.
{#CJS-getDescription__table_g5q_3qz_sbb__entry__3}

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

{#CJS-getDescription__table_g5q_3qz_sbb} {#CJS-getDescription__table_h5q_3qz_sbb__entry__2}

| Type | Description |
|-|-|
| String | Catalog description. |
[Table 16. Returns]

{#CJS-getDescription__table_h5q_3qz_sbb}  
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() {#ariaid-title11}

Returns the catalog desktop image file name.
{#CJS-getDesktopImageSRC__table_zdf_csz_sbb__entry__3}

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

{#CJS-getDesktopImageSRC__table_zdf_csz_sbb} {#CJS-getDesktopImageSRC__table_a2f_csz_sbb__entry__2}

| Type | Description |
|-|-|
| String | Catalog desktop image file name. |
[Table 18. Returns]

{#CJS-getDesktopImageSRC__table_a2f_csz_sbb}  
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() {#ariaid-title12}

Returns the current catalog's GlideRecord.
{#CJS-getGr__table_vdd_rqz_sbb__entry__3}

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

{#CJS-getGr__table_vdd_rqz_sbb} {#CJS-getGr__table_wdd_rqz_sbb__entry__2}

| Type | Description |
|-|-|
| GlideRecord | GlideRecord of the current catalog. |
[Table 20. Returns]

{#CJS-getGr__table_wdd_rqz_sbb}  
This example returns the GlideRecord for the specified catalog.

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

## CatalogJS - getHeaderIconSRC() {#ariaid-title13}

Returns the current catalog's header icon.
{#CJS-getHeaderIconSRC__table_xsg_5rz_sbb__entry__3}

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

{#CJS-getHeaderIconSRC__table_xsg_5rz_sbb} {#CJS-getHeaderIconSRC__table_ysg_5rz_sbb__entry__2}

| Type | Description |
|-|-|
| String | Catalog header icon. |
[Table 22. Returns]

{#CJS-getHeaderIconSRC__table_ysg_5rz_sbb}  
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() {#ariaid-title14}

Returns the sys_id of the current catalog.
{#CJS-getID__table_xqx_xpz_sbb__entry__3}

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

{#CJS-getID__table_xqx_xpz_sbb} {#CJS-getID__table_yqx_xpz_sbb__entry__2}

| Type | Description |
|-|-|
| String | Sys_id of the current catalog. |
[Table 24. Returns]

{#CJS-getID__table_yqx_xpz_sbb}  
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() {#ariaid-title15}

Returns the title of the current catalog.
{#CJS-getTitle__table_fxp_mxz_sbb__entry__3}

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

{#CJS-getTitle__table_fxp_mxz_sbb} {#CJS-getTitle__table_gxp_mxz_sbb__entry__2}

| Type | Description |
|-|-|
| String | Title of the current catalog. |
[Table 26. Returns]

{#CJS-getTitle__table_gxp_mxz_sbb}  
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() {#ariaid-title16}

Specifies if the current catalog has categories.
{#CJS-hasCategories__table_kwh_lsz_sbb__entry__3}

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

{#CJS-hasCategories__table_kwh_lsz_sbb} {#CJS-hasCategories__table_lwh_lsz_sbb__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the current catalog has categories. Valid values: * true: Catalog has categories. * false: Catalog does not have categories. {#CJS-hasCategories__ul_l1q_qn4_kpb} |
[Table 28. Returns]

{#CJS-hasCategories__table_lwh_lsz_sbb}  
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() {#ariaid-title17}

Specifies if the current catalog has catalog items.
{#CJS-hasItems__table_abg_5wz_sbb__entry__3}

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

{#CJS-hasItems__table_abg_5wz_sbb} {#CJS-hasItems__table_bbg_5wz_sbb__entry__2}

| 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. {#CJS-hasItems__ul_l1q_qn4_kpb} |
[Table 30. Returns]

{#CJS-hasItems__table_bbg_5wz_sbb}  
Example:

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

Output:

    true

## CatalogJS - isWishlistEnabled() {#ariaid-title18}

Specifies if the wish list is enabled for the current catalog.
{#CJS-isWishlistEnabled__table_emb_xk2_sbb__entry__3}

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

{#CJS-isWishlistEnabled__table_emb_xk2_sbb} {#CJS-isWishlistEnabled__table_fmb_xk2_sbb__entry__2}

| 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. {#CJS-isWishlistEnabled__ul_l1q_qn4_kpb} |
[Table 32. Returns]

{#CJS-isWishlistEnabled__table_fmb_xk2_sbb}  
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


