{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":970,"path":"api-reference/server-api-reference/c_CatCategory.md","title":"CatCategory - Scoped","bundle":null,"doc_type":null,"release":"australia","body":"\n# CatCategory- Scoped\n\nThe CatCategory API provides methods that enable you to create and modify service catalog categories using scripts.\n\nThis API runs in the `sn_sc` namespace.\n\n**Important:** This API is accessible; however, the recommended implementation is the [Service Catalog REST API](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-apis/c_ServiceCatalogAPI.md).\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## CatCategory - availableForUserCriteria\\(String action, Array criteriaIDs\\)\n\nAdds the **Available For** user criteria to the current catalog category.\n\n<table id=\"table_oz2_pln_vz\" 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\naction\n\n</td><td>\n\nString\n\n</td><td>\n\nAction to perform.-   `add`: Adds the user criteria to the **Available For** list.\n-   `delete`: Deletes the user criteria from the **Available For** list.\n\n</td></tr><tr><td>\n\ncriteriaIDs\n\n</td><td>\n\nArray\n\n</td><td>\n\nArray of the user criteria sys\\_ids.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar item = new sn_sc.CatCategory(\"31bea3d53790200044e0bfc8bcbe5dec\");\nitem.availableForUserCriteria(\"add\", [\"0c441abbc6112275000025157c651c89\"]);\n```\n\n## CatCategory - canView\\(Boolean isMobile, String userSysId\\)\n\nDetermines whether a specified user can view a specified category on a mobile device or desktop.\n\n<table id=\"table_j5n_smk_chb\" 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\nisMobile\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether to verify the user for access on a mobile device or desktop.-   true: Validate for mobile.\n-   false: Validate for desktop.\n\n</td></tr><tr><td>\n\nuserSysId\n\n</td><td>\n\nString\n\n</td><td>\n\nSys\\_id of the user to validate.\n\n</td></tr></tbody>\n</table><table id=\"table_k5n_smk_chb\" 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 user can view the associated category.-   true: User can view the category.\n-   false: User cannot view the category.\n\n</td></tr></tbody>\n</table>```\nvar scopedCategoryObj = new sn_sc.CatCategory('7b1262b9530033007444ddeeff7b12ae');\nscopedCategoryObj.canView(false, '62826bf03710200044e0bfc8bcbe5df1');\n```\n\n## CatCategory - create\\(Boolean standardUpdate\\)\n\nInsert the defined category.\n\n<table id=\"table_afn_1b2_ns\" 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\nstandardUpdate\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether to enable the running of engines and workflow.Valid values:\n\n-   true: Enable engines and workflow.\n-   false: Do not enable engines and workflow.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|String|Sys\\_id of the inserted variable record.|\n\n```\nvar categoryCreate = new sn_sc.CatCategory();\ncategoryCreate.setAttributes({\"title\" : \"test a scoped category\", \"sc_catalog\" : \"e0d08b13c3330100c8b837659bba8fb4\"});\nvar categorySysId = categoryCreate.create();\nvar isValidSysId = categorySysId.match(/^[0-9a-fA-F]{32}$/) == null ? false : true;\nglobal.Assert.assertEquals(true, isValidSysId,\"CategorySysId: [\"+ categorySysId +\"] is not valid\", true, isValidSysId);\n```\n\n## CatCategory - deleteRecord\\(Boolean standardUpdate\\)\n\nDeletes the category record on which the CatCategory class was initially instantiated.\n\n<table id=\"table_xzp_4b2_ns\" 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\nstandardUpdate\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether to enable the running of engines and workflow.Valid values:\n\n-   true: Enable engines and workflow.\n-   false: Do not enable engines and workflow.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar categoryDelete = new sn_sc.CatCategory(categorySysId);\ncategoryDelete.deleteRecord();\nvar category = new sn_sc.CatCategory(categorySysId);\nvalues = category.read({\"title\" : \"\", \"sc_catalog\":\"\"}, false);\nglobal.Assert.assertEquals(\"\", values.title,\"Category should title\");\n```\n\n## CatCategory - getID\\(\\)\n\nReturns the sys\\_id of the current category.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Sys\\_id of the current category.|\n\nExample:\n\n```\nvar cart = new sn_sc.CatCategory(\"2809952237b1300054b6a3549dbe5dd4\");\nvar categoryID = cart.getID();\ngs.info(categoryID);\n```\n\nOutput:\n\n```\n2809952237b1300054b6a3549dbe5dd4\n```\n\n## CatCategory - notAvailableForUserCriteria\\(String action, Array\\[\\] criteriaIDs\\)\n\nAdds the **Not Available For** user criteria to a catalog category.\n\n<table id=\"table_yxb_1mn_vz\" 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\naction\n\n</td><td>\n\nString\n\n</td><td>\n\nAction to perform.-   `add`: Adds the user criteria to the **Not Available For** list.\n-   `delete`: Deletes the user criteria from the **Not Available For** list.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar item = new sn_sc.CatCategory(\"31bea3d53790200044e0bfc8bcbe5dec\");\nitem. notAvailableForUserCriteria(\"add\", [\"0c441abbc6112275000025157c651c89\"]);\n```\n\n## CatCategory - read\\(Object columns, Boolean standardUpdate\\)\n\nReturns a mapping of the category.\n\n<table id=\"table_p2h_5b2_ns\" 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\ncolumns\n\n</td><td>\n\nObject\n\n</td><td>\n\nSet of columns that you would like the values for.\n\n</td></tr><tr><td>\n\nstandardUpdate\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether to enable the running of engines and workflow.Valid values:\n\n-   true: Enable engines and workflow.\n-   false: Do not enable engines and workflow.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|Object|Mapping of column names to values.|\n\n```\nvar category = new sn_sc.CatCategory(\"a96277509f300200b407b89a442e704e\");\nvar values = category.read({\"title\" : \"\"}, true);\ngs.log(values.title);\n```\n\n## CatCategory - setAttributes\\(Object attributes\\)\n\nDefines the attribute values for this category.\n\n|Name|Type|Description|\n|----|----|-----------|\n|attributes|Object|Attributes for the new field and value pairs.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar categoryCreate = new sn_sc.CatCategory();\ncategoryCreate.setAttributes({\"title\" : \"test a scoped category\", \"sc_catalog\" : \"e0d08b13c3330100c8b837659bba8fb4\"});\nvar categorySysId = categoryCreate.create();\nvar isValidSysId = categorySysId.match(/^[0-9a-fA-F]{32}$/) == null ? false : true;\nglobal.Assert.assertEquals(true, isValidSysId,\"CategorySysId: [\"+ categorySysId +\"] is not valid\", true, isValidSysId);\n```\n\n## CatCategory - setTableName\\(String tableName\\)\n\nDefines the table name for this category.\n\n|Name|Type|Description|\n|----|----|-----------|\n|tableName|String|Name of the table that extends sc\\_category.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar categoryRead = new sn_sc.CatCategory(categorySysId);\ncategoryRead.setTableName(\"test_category\");\nvar values = categoryRead.read({\"title\" : \"\", \"sc_catalog\":\"\", \"test\": \"\"}, false);\ngs.info(categorySysId);\ngs.info(values.title);\ngs.info(values.test);\nglobal.Assert.assertEquals(\"testValue\", values.test,\"Category extends sc_category and stores its extended value\");\n```\n\n## CatCategory - update\\(Object columnValues, Boolean standardUpdate\\)\n\nUpdates the current category with the specified name-value pairs.\n\n<table id=\"table_dfz_fb2_ns\" 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\ncolumnValues\n\n</td><td>\n\nObject\n\n</td><td>\n\nMapping of column names to values.\n\n</td></tr><tr><td>\n\nstandardUpdate\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether to enable the running of engines and workflow.Valid values:\n\n-   true: Enable engines and workflow.\n-   false: Do not enable engines and workflow.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar categoryUpdate = new sn_sc.CatCategory(categorySysId);\ncategoryUpdate.update({\"title\" : \"test changed scoped category\"}, true);\nvalues = categoryUpdate.read({\"title\" : \"\", \"sc_catalog\":\"\"}, false);\nglobal.Assert.assertEquals(\"test changed scoped category\", values.title,\"Category should title\");\n```\n\n"}}