CatItem - Scoped
-
- UpdatedJan 30, 2025
- 9 minutes to read
- Yokohama
- API reference
The CatItem API provides methods that enable you to create and modify service catalog items using scripts.
This API runs in the sn_sc
namespace.
CatItem - availableForUserCriteria(String action, Array criteriaIDs)
Adds the Available For user criteria to the current catalog item.
Name | Type | Description |
---|---|---|
action | String | Action to perform.
|
criteriaIDs | Array | Array of the user criteria sys_ids. |
Type | Description |
---|---|
void |
Example
This example shows how to add the specified Available For user criteria.
CatItem - canViewInDomain()
Verifies whether the current catalog item is viewable in the selected domain (domain selected in the domain picker).
Catalog items in the global domain are available across all domains.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Boolean | Flag that validates whether the current catalog item is viewable in the
selected domain. Valid values:
|
Example
This example shows how to verify whether a catalog item is viewable in the currently selected domain.
CatItem - canViewOnSearch(boolean isMobile)
Determines if the user has access to view the catalog item on global search.
Name | Type | Description |
---|---|---|
isMobile | Boolean | Flag that indicates whether to perform the search for the mobile or desktop view. Valid values:
|
Type | Description |
---|---|
Boolean | Flag that indicates whether the user has access to view the catalog item on global search. Valid values:
|
Example
This code example shows how to check if the user has access to view the catalog item on global search in desktop view.
Output:
CatItem - create(Boolean standardUpdate)
Inserts the defined catalog item.
Name | Type | Description |
---|---|---|
standardUpdate | Boolean | Flag that indicates whether to enable the running of engines and
workflow. Valid values:
|
Type | Description |
---|---|
String | Sys_id of the newly created catalog item. |
Example
This example creates a new catalog item and adds a variable and variable set.
Output:
CatItem - deleteRecord(Boolean standardUpdate)
Deletes a catalog item.
Name | Type | Description |
---|---|---|
standardUpdate | Boolean | Flag that indicates whether to enable the running of engines and
workflow. Valid values:
|
Type | Description |
---|---|
void |
Example
This example deletes all inactive catalog items.
CatItem - getFirstAccessibleCategoryForSearch(String catalogId)
Returns the first category that the user can view in a catalog.
Name | Type | Description |
---|---|---|
catalogId | String | Sys_id of the catalog. |
Type | Description |
---|---|
String | Sys_id of the first category that the user can view in a catalog. |
Example
Example:
Output:
CatItem - getInvalidDelegatedUsers(Array requestForUsers)
Returns an array of users for whom the associated item cannot be delegated (requested on behalf of).
The method verifies each of the users passed in the array.
Name | Type | Description |
---|---|---|
requestForUsers | Object | Array of user sys_ids to check whether the associated user can acquire the current item and that the item can be requested on behalf of them. Table: User [sys_user] |
Type | Description |
---|---|
Array | List of user names (Name column from Users [sys_user] table) for whom the item can't be requested for by a delegate. |
Example
This example shows how to obtain a list of user names for whom the item can't be requested for by a delegate.
Output:
CatItem - getRecordClass()
Returns the class name for the current catalog item record.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Class name for the current catalog item record. |
Example
Example:
Output:
CatItem - isDelegationAllowed(String delegatedUser)
Verifies whether the specified delegated user has acquisition rights to the current service catalog item.
Name | Type | Description |
---|---|---|
delegatedUser | String | Optional. Sys_id of the user to request the service catalog item for
(delegate). The method verifies whether the user has acquisition rights to the
item. Default: Checks whether the calling user has acquisition rights to the item. |
Type | Description |
---|---|
Boolean | Flag that indicates whether the user has acquisition rights to the current
service catalog item. Valid values:
|
Example
This code example shows how to determine if delegation is allowed for the catalog item.
Output: true
CatItem - isVisibleServicePortal()
Determines if the current catalog item is available in service portal.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Boolean | Flag that indicates whether the catalog item is available in the Service Portal. Valid values:
|
Example
Example:
Output:
CatItem - notAvailableForUserCriteria(String action, Array criteriaIDs)
Adds the Not Available For user criteria to a catalog item.
Name | Type | Description |
---|---|---|
action | String | Action to perform.
|
Type | Description |
---|---|
void |
Example
This example shows how to add the specified Not Available For user criteria.
CatItem - read(Object columns, Boolean standardUpdate)
Returns a mapping of catalog item attribute values.
Name | Type | Description |
---|---|---|
columns | Object | Name-value pairs of columns for which to return values. |
standardUpdate | Boolean | Flag that indicates whether to enable the running of engines and
workflow. Valid values:
|
Type | Description |
---|---|
Object | Mapping of column names to values. |
Example
This example reads the name and price fields of a catalog item.
CatItem - setAttributes(Object attributes)
Sets attributes for a catalog item.
Name | Type | Description |
---|---|---|
attributes | Object | Name-value pairs of the columns for which to set. |
Type | Description |
---|---|
void |
Example
This example sets attributes for a new catalog item.
Output:
CatItem - setCatalogs(String catalogs)
Defines the catalogs that this catalog item is associated with.
Name | Type | Description |
---|---|---|
catalogs | String | Comma-separated list of sys_ids of the catalogs to associate with the item the item. |
Type | Description |
---|---|
void |
Example
This example associates a catalog item with two catalogs.
CatItem - setCategories(String categories)
Defines the categories that this catalog item is associated with.
Name | Type | Description |
---|---|---|
categories | String | Comma-separated list of sys_ids of the categories to associate with the item the item. |
Type | Description |
---|---|
void |
Example
This example shows how to associate two categories to an item.
CatItem - setImage(String dbImageSysId, String type)
Adds an image to a catalog item.
Name | Type | Description |
---|---|---|
dbImageSysId | String | Sys_id of the image from the Images table [db_image]. |
type | String | Type of image. Valid values:
|
Type | Description |
---|---|
void |
Example
This example adds an image to a catalog item.
CatItem - setTableName(String tableName)
Defines the table name for this catalog item.
Name | Type | Description |
---|---|---|
tableName | String | Name of the table that extends Catalog Item [sc_cat_item]. |
Type | Description |
---|---|
void |
Example
This example shows how to set the name of an extended table.
CatItem - submitProducer(Object values)
Creates a record using a specified Service Catalog record producer.
Name | Type | Description |
---|---|---|
values | Object | Contains the field values and record producer to use when creating the record. |
values.variables | Object | The field values to set for the new record. |
values.sysparm_id | String | Sys_id of the record producer to use from the Record Producer [sc_cat_item_producer] table. |
Example
This example creates an incident using the Create Incident record producer.
Output:
CatItem - update(Object columnValues, Boolean standardUpdate)
Updates the values for specified fields of a catalog item.
Name | Type | Description |
---|---|---|
columnValues | Object | Name-value pairs of the fields to update and their associated values. |
standardUpdate | Boolean | Flag that indicates whether to enable the running of engines and
workflow. Valid values:
|
Type | Description |
---|---|
void |
Example
This example updates the name, short description, and price of an existing catalog item.
On this page
- CatItem - availableForUserCriteria(String action, Array criteriaIDs)
- CatItem - canViewInDomain()
- CatItem - canViewOnSearch(boolean isMobile)
- CatItem - create(Boolean standardUpdate)
- CatItem - deleteRecord(Boolean standardUpdate)
- CatItem - getFirstAccessibleCategoryForSearch(String catalogId)
- CatItem - getInvalidDelegatedUsers(Array requestForUsers)
- CatItem - getRecordClass()
- CatItem - isDelegationAllowed(String delegatedUser)
- CatItem - isVisibleServicePortal()
- CatItem - notAvailableForUserCriteria(String action, Array criteriaIDs)
- CatItem - read(Object columns, Boolean standardUpdate)
- CatItem - setAttributes(Object attributes)
- CatItem - setCatalogs(String catalogs)
- CatItem - setCategories(String categories)
- CatItem - setImage(String dbImageSysId, String type)
- CatItem - setTableName(String tableName)
- CatItem - submitProducer(Object values)
- CatItem - update(Object columnValues, Boolean standardUpdate)