{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":715,"path":"api-reference/server-api-reference/CSBScratchpadUtilScopedAPI.md","title":"CSBScratchpadUtil - Scoped","bundle":null,"doc_type":null,"release":"australia","body":"\n# CSBScratchpadUtil- Scoped\n\nThe CSBScratchpadUtil API allows consumers to share \"extra\" information that is outside of any other Service Exchange service, with their providers.\n\nThis information is stored as name-value pairs in the Scratchpad \\[sn\\_sb\\_scratchpad\\] table. The shared information must be associated with tasks that are of one of two types: provider tasks or remote tasks.\n\nIf the associated task is active, the updated scratchpad information syncs to the consumer instance. If a task is deactivated or deleted, the information in the scratchpad is also deleted after a specified number of days; by default three. This default is defined in the sn\\_sb.scratchpad.autodelete.days property.\n\nBoth providers and consumers can add, update, and remove information to and from the Scratchpad table. Producers update this information using the [PSBScratchpadUtil - Scoped](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/PSBScratchpadUtilScopedAPI.md) API.\n\nTo access this API, the Service Exchange for Consumers application must be installed. This API runs in the `sn_sb_con` namespace.\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## CSBScratchpadUtil - get\\(GlideRecord taskGR, String name\\)\n\nReturns the value of a specified scratchpad property.\n\n<table id=\"table_sm3_fpg_czb\" 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\ntaskGR\n\n</td><td>\n\nGlideRecord\n\n</td><td>\n\nGlideRecord of the active remote task or provider task associated with the specified scratchpad property. Tables: Remote task \\[sn\\_sb\\_con\\_remote\\_task\\] and Provider task \\[sn\\_sb\\_con\\_provider\\_task\\].\n\n</td></tr><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nName of the scratchpad property whose value to retrieve. Table: Scratchpad \\[sn\\_sb\\_scratchpad\\]\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|String or null|Value of the requested scratchpad property. Null if the property isn't found.|\n\nThe following code example shows how to call this method.\n\n```\nvar rtGR = new GlideRecord(\"sn_sb_con_remote_task\");\nrtGR.setLimit(1); \nrtGR.query();  \nrtGR.next() \nif (rtGR.isValidRecord()) { \n  var util = new sn_sb_con.CSBScratchpadUtil();\n  util.update(rtGR, \"name1\", \"value1\"); \n  gs.info(util.get(rtGR, \"name1\"));\n}\n```\n\nOutput:\n\n```\n\"value1\"\n```\n\n## CSBScratchpadUtil - getAll\\(GlideRecord taskGR\\)\n\nReturns the property names and values \\(name-value pairs\\) of all scratchpad properties associated with the specified task.\n\n<table id=\"table_ism_vpg_czb\" 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\ntaskGR\n\n</td><td>\n\nGlideRecord\n\n</td><td>\n\nGlideRecord of the active remote task or provider task whose associated scratchpad properties to return. Table: Remote task \\[sn\\_sb\\_con\\_remote\\_task\\] and Provider task \\[sn\\_sb\\_con\\_provider\\_task\\] tables.\n\n</td></tr></tbody>\n</table><table id=\"table_jsm_vpg_czb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nObject\n\n</td><td>\n\nAll property names and values contained in the specified task. For example:\n\n`{ name1: value1, name2: value2, … }`\n\n</td></tr></tbody>\n</table>The following code example shows how to call this method.\n\n```\nvar rtGR = new GlideRecord(\"sn_sb_con_remote_task\");\nrtGR.setLimit(1);\nrtGR.query();  \nrtGR.next() \nif (rtGR.isValidRecord()) {  \n  var util = new sn_sb_con.CSBScratchpadUtil();\n  util.update(rtGR, \"name1\", \"value1\"); \n  gs.info(JSON.stringify(util.getAll(rtGR))); \n}\n```\n\nOutput:\n\n```\n{ \"name1\": \"value1\" }\n```\n\n## CSBScratchpadUtil - getNames\\(GlideRecord taskGR\\)\n\nReturns the list of names of all scratchpad properties associated with the specified task record.\n\n<table id=\"table_r5k_dqg_czb\" 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\ntaskGR\n\n</td><td>\n\nGlideRecord\n\n</td><td>\n\nGlideRecord of the active remote task or provider task for which to return the list of names of all associated scratchpad properties. Table: Remote task \\[sn\\_sb\\_con\\_remote\\_task\\] and Provider task \\[sn\\_sb\\_con\\_provider\\_task\\]\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|String Array|List of names of the scratchpad properties associated with the specified task record.|\n\nThe following code example shows how to call this method.\n\n```\nvar rtGR = new GlideRecord(\"sn_sb_con_remote_task\");\nrtGR.setLimit(1); \nrtGR.query();  \nrtGR.next() \nif (rtGR.isValidRecord()) {\n  var util = new sn_sb_con.CSBScratchpadUtil();\n  util.update(rtGR, \"name1\", \"value1\"); \n  gs.info(JSON.stringify(util.getNames(rtGR))); \n}\n```\n\nOutput:\n\n```\n[ \"name1\" ]\n```\n\n## CSBScratchpadUtil - populateClientScratchpadBR\\(GlideRecord taskGR\\)\n\nPlaces the scratchpad properties associated with the specified remote task or provider task in the client g\\_scratchpad.\n\nYou can call this method from a UI display business rule.\n\n<table id=\"table_ikg_qdb_fzb\" 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\ntaskGR\n\n</td><td>\n\nGlideRecord\n\n</td><td>\n\nGlideRecord of the active remote task or provider task whose associated scratchpad entries should be placed in the client g\\_scratchpad. Tables: Remote task \\[sn\\_sb\\_con\\_remote\\_task\\] and Provider task \\[sn\\_sb\\_con\\_provider\\_task\\]\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nThe following code example shows how to call this method.\n\n```\nnew sn_sb_con.CSBScratchpadUtil().populateClientScratchpadBR(current);\n```\n\n## CSBScratchpadUtil - remove\\(GlideRecord taskGR, String name\\)\n\nDeletes the specified scratchpad property from the Scratchpad \\[sn\\_sb\\_scratchpad\\] table.\n\n**Note:** Deletes are not synced to other ServiceNow instances. Scratchpad properties are automatically deleted in a specified number of days after the associated task record is deactivated or deleted.\n\n<table id=\"table_x3b_nqg_czb\" 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\ntaskGR\n\n</td><td>\n\nGlideRecord\n\n</td><td>\n\nGlideRecord of the active remote task or provider task associated with the specified scratchpad property. Tables: Remote task \\[sn\\_sb\\_con\\_remote\\_task\\] and Provider task \\[sn\\_sb\\_con\\_provider\\_task\\].\n\n</td></tr><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nName of the scratchpad property to remove from the Scratchpad \\[sn\\_sb\\_scratchpad\\] table.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nThe following code example shows how to call this method.\n\n```\nvar rtGR = new GlideRecord(\"sn_sb_con_remote_task\");\nrtGR.setLimit(1); \nrtGR.query();  \nrtGR.next() \nif (rtGR.isValidRecord()) {\n  var util = new sn_sb_con.CSBScratchpadUtil();\n  util.update(rtGR, \"name1\", \"value1\"); \n  util.remove(rtGR, “name1”);\n  gs.info(util.get(rtGR, \"name1\")); \n}\n```\n\nOutput:\n\n```\nundefined\n```\n\n## CSBScratchpadUtil - update\\(GlideRecord taskGR, String name, String value, Boolean client\\_side\\_accessible\\)\n\nInserts a property or updates the value of a property in the Scratchpad \\[sn\\_sb\\_scratchpad\\] table.\n\n**Note:** The maximum number of properties that you can update in one call is 50.\n\n<table id=\"table_z4p_4kg_czb\" 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\ntaskGR\n\n</td><td>\n\nGlideRecord\n\n</td><td>\n\nGlideRecord of the active remote task or provider task associated with the specified scratchpad property. Tables: Remote task \\[sn\\_sb\\_con\\_remote\\_task\\] and Provider task \\[sn\\_sb\\_con\\_provider\\_task\\]\n\n</td></tr><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nName of a new or existing scratchpad property. This name must be unique across all scratchpad properties.\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nString\n\n</td><td>\n\nValue of the scratchpad property. Maximum: 4000 characters.\n\n</td></tr><tr><td>\n\nclient\\_side\\_accessible\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nOptional. Flag that indicates whether this property is available to the client-side g\\_scratchpad when populateClientScratchpadBR is called from a display business rule.Valid values:\n\n-   true: Property is available.\n-   false: Property isn't available.\n\nDefault: false\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nThe following code example shows how to call this method.\n\n```\nvar rtGR = new GlideRecord(\"sn_sb_con_remote_task\");\nrtGR.setLimit(1); \nrtGR.query();\nrtGR.next()\nif (rtGR.isValidRecord()) {\n  var util = new sn_sb_con.CSBScratchpadUtil();\n  util.update(rtGR, \"name1\", \"value2\");\n  gs.info(util.get(rtGR, \"name1\")); \n} \n```\n\nOutput:\n\n```\n\"value2\"\n```\n\n"}}