{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":719,"path":"api-reference/server-api-reference/CatalogJSScopedAPI.md","title":"CatalogJS - Scoped","bundle":null,"doc_type":null,"release":"australia","body":"\n# CatalogJS- Scoped\n\nThe CatalogJS API provides methods to check and retrieve catalog-specific properties.\n\nTo 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.\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## CatalogJS - Catalog\\(GlideRecord now\\_GR\\)\n\nCreates an instance of the catalog class for the specified glide record object.\n\n|Name|Type|Description|\n|----|----|-----------|\n|now\\_GR|Object|Glide Record pointing to the sc\\_catalog table.|\n\nThis example shows how to create a new instance of the catalog class.\n\n```\nvar now_GR = new GlideRecord('sc_catalog');\n now_GR.addQuery('sys_id','e0d08b13c3330100c8b837659bba8fb4');\n now_GR.query();\n var catalog = new sn_sc.Catalog(now_GR);\n```\n\n## CatalogJS - Catalog\\(String sys\\_id\\)\n\nCreates an instance of the Catalog class with the specified sys\\_id.\n\n|Name|Type|Description|\n|----|----|-----------|\n|sys\\_id|String|Sys\\_id of the catalog.|\n\nThis example shows how to create an instance of the Catalog class wit the specified syst\\_id.\n\n```\nnew sn_sc.Catalog(catalog_sys_id);\nvar catalog = new sn_sc.Catalog(\"31bea3d53790200044e0bfc8bcbe5dec\");\n```\n\n## CatalogJS - canView\\(Boolean mobile, String userId\\)\n\nDetermines whether a user can view the current category on a mobile device or desktop.\n\n<table id=\"table_mnl_2lz_sbb\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nmobile\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether to check if the user can view the current catalog on a mobile view or desktop view.\n\n Valid values:\n\n-   true: Mobile view\n-   false: Desktop view\n\n</td></tr><tr><td>\n\nuserId\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional. Sys\\_id of the user to check if they can view the catalog.Default: Current user\n\n</td></tr></tbody>\n</table><table id=\"table_nnl_2lz_sbb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the catalog is viewable by the user.\n\n Valid values:\n\n-   true: Catalog is viewable by the user.\n-   false: Catalog is not viewable by the user.\n\n</td></tr></tbody>\n</table>Example:\n\n```\nvar catalog = new sn_sc.Catalog(\"e0d08b13c3330100c8b837659bba8fb4\");\ngs.info(catalog.canView(true));\n```\n\nOutput:\n\n```\ntrue\n```\n\n## CatalogJS - getAvailableCatalog\\(\\)\n\nReturns the available active catalog.\n\nIf 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.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Object|Object pointing to the earliest catalog that the user can view, or null if no catalog is available.|\n\nThis example returns the catalog that is available to the current user.\n\n```\nvar catalog = sn_sc.Catalog.getAvailableCatalog()\n```\n\n## CatalogJS - getBackgroundColor\\(\\)\n\nReturns the catalog background color.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Background color of the catalog.|\n\nThis example returns the background color for the associated catalog.\n\n```\nvar catalog = new sn_sc.Catalog(\"0f910a2ac3112200b12d9f2974d3ae3c\");\ngs.info(\"Catalog background: \" + catalog.getBackgroundColor());\n```\n\nOutput:\n\n```\nCatalog background: white\n```\n\n## CatalogJS - getCatalogCount\\(\\)\n\nReturns the number of catalogs active in the catalog table.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Integer|Number of catalogs available in the catalog table.|\n\nExample:\n\n```\nconsole.log(sn_sc.Catalog.getCatalogCount());\n```\n\nOutput:\n\n```\n3\n```\n\n## CatalogJS - getCategories\\(\\)\n\nReturns the categories for the current catalog.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|ArrayList|Returns the categories for the current catalog.|\n\nThis example returns the categories available in the current catalog object.\n\n```\nvar catalog=new sn_sc.Catalog(\"e0d08b13c3330100c8b837659bba8fb4\");\nconsole.log(catalog.getCategories());\n```\n\nOutput:\n\n```\n0 : {header_image: \"\", sys_id: \"e15706fc0a0a0aa7007fc21e1ab70c2f\", description: \"Your IT gateway. Report issues and submit requests.\", title: \"Can We Help You?\"} \n1 : {header_image: \"\", sys_id: \"95fc11615f1211001c9b2572f2b477c6\", description: \"Services offered by different departments in the organization\", title: \"Departmental Services\"} \n2 : {header_image: \"\", sys_id: \"900682363731300054b6a3549dbe5d5f\", description: \"Desktop computers for your work area.\", title: \"Desktops\"} \n3 : {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\"} \n4 : {header_image: \"\", sys_id: \"d258b953c611227a0146101fb1be7c31\", description: \"Order from a variety of hardware to meet your business needs, including phones, tablets and laptops.\", title: \"Hardware\"} \n```\n\n## CatalogJS - getCategoryIds\\(\\)\n\nSpecifies the sys\\_ids of the categories in the current catalog.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|ArrayList|Returns the sys\\_ids of the categories in the current catalog.|\n\nThis example returns the sys\\_ids of the categories available in the current catalog.\n\n```\nvar catalog=new sn_sc.Catalog(\"e0d08b13c3330100c8b837659bba8fb4\");\nconsole.log(catalog.getCategoryIds());\n```\n\nOutput:\n\n```\n0:\"e15706fc0a0a0aa7007fc21e1ab70c2f\"\n1 : \"95fc11615f1211001c9b2572f2b477c6\"\n2 : \"900682363731300054b6a3549dbe5d5f\"\n3 : \"d2f716fcc611227a015a142fa0b262c1\"\n```\n\n## CatalogJS - getDescription\\(\\)\n\nReturns the description of the current catalog.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Catalog description.|\n\nThis example returns the name of the current catalog.\n\n```\nvar catalog=new sn_sc.Catalog(\"e0d08b13c3330100c8b837659bba8fb4\");\nconsole.log(catalog.getDescription());\n```\n\nOutput:\n\n```\nService Catalog - IT Now\n```\n\n## CatalogJS - getDesktopImageSRC\\(\\)\n\nReturns the catalog desktop image file name.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Catalog desktop image file name.|\n\nThis example returns the current catalog desktop image file name.\n\n```\nvar catalog=new sn_sc.Catalog(\"e0d08b13c3330100c8b837659bba8fb4\");\nconsole.log(catalog.getDesktopImageSRC());\n```\n\nOutput:\n\n```\nadbcc271475211002ee987e8dee49001.iix\n```\n\n## CatalogJS - getGr\\(\\)\n\nReturns the current catalog's GlideRecord.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|GlideRecord|GlideRecord of the current catalog.|\n\nThis example returns the GlideRecord for the specified catalog.\n\n```\nvar catalog = new sn_sc.Catalog(\"e0d08b13c3330100c8b837659bba8fb4\");\ndata.history = catalog.getGr();\n```\n\n## CatalogJS - getHeaderIconSRC\\(\\)\n\nReturns the current catalog's header icon.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Catalog header icon.|\n\nThis example shows how to obtain the name of the catalog header icon.\n\n```\nvar catalog=new sn_sc.Catalog(\"e0d08b13c3330100c8b837659bba8fb4\");\ngs.info(catalog.getHeaderIconSRC());\n```\n\nOutput:\n\n```\nservice_catalog_header.png\n```\n\n## CatalogJS - getID\\(\\)\n\nReturns the sys\\_id of the current catalog.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Sys\\_id of the current catalog.|\n\nThis example returns the sys\\_id of the current catalog.\n\n```\nvar catalog=new sn_sc.Catalog(\"e0d08b13c3330100c8b837659bba8fb4\");\nconsole.log(catalog.getId());\n```\n\nOutput:\n\n```\ne0d08b13c3330100c8b837659bba8fb4\n```\n\n## CatalogJS - getTitle\\(\\)\n\nReturns the title of the current catalog.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Title of the current catalog.|\n\nThis example returns the title of the current catalog.\n\n```\nvar catalog=new sn_sc.Catalog(\"e0d08b13c3330100c8b837659bba8fb4\");\ngs.info(catalog.getTitle());\n```\n\nOutput:\n\n```\nService Catalog\n```\n\n## CatalogJS - hasCategories\\(\\)\n\nSpecifies if the current catalog has categories.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_lwh_lsz_sbb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the current catalog has categories.\n\n Valid values:\n\n-   true: Catalog has categories.\n-   false: Catalog does not have categories.\n\n</td></tr></tbody>\n</table>This examples shows how to determine if the current catalog contains categories.\n\n```\nvar catalog=new sn_sc.Catalog(\"e0d08b13c3330100c8b837659bba8fb4\");\ngs.info(catalog.hasCategories());\n```\n\nOutput:\n\n```\nfalse\n```\n\n## CatalogJS - hasItems\\(\\)\n\nSpecifies if the current catalog has catalog items.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_bbg_5wz_sbb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the current catalog has catalog items.\n\n Valid values:\n\n-   true: Catalog has catalog items.\n-   false: Catalog does not have catalog items.\n\n</td></tr></tbody>\n</table>Example:\n\n```\nvar catalog=new sn_sc.Catalog(\"e0d08b13c3330100c8b837659bba8fb4\");\ngs.info(catalog.hasItems());\n```\n\nOutput:\n\n```\ntrue\n```\n\n## CatalogJS - isWishlistEnabled\\(\\)\n\nSpecifies if the wish list is enabled for the current catalog.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_fmb_xk2_sbb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the current catalog supports wish lists.\n\n Valid values:\n\n-   true: Catalog supports wish lists.\n-   false: Catalog does not support wish lists.\n\n</td></tr></tbody>\n</table>This example shows how to check if a wish lists are enabled for the current catalog.\n\n```\nvar catalog = new sn_sc.Catalog(\"e0d08b13c3330100c8b837659bba8fb4\");\ngs.info(catalog.isWishlistEnabled());\n\n```\n\nOutput:\n\n```\ntrue\n```\n\n"}}