Data Stores
Data stores are persistent key-value pairs linked to a record, stored in the x_snd_eb_data_store table and accessible via the dataStore API. Values are stored as strings, with methods that allow them to be retrieved as strings or automatically converted to and from objects when required.
Usage
Data Stores are used primarily in Message Scripts and Poll Processor scripts when you want to get and set functional data that is relevant to the integration but does not belong on the target record.
This is particularly handy in a uni-directional integration where polling the remote system is necessary. You can store data such as:
The last time a request was made
Identifiers that have been seen before
Watermarks
Model API
All Unifi model objects have data store built in. Calling these methods will read/write data stores on the record the object is representing.
getData(key [, default_value])
Get a string value from a data store. The default_value parameter will be returned if no data store exists on the model with the specified key.
bond.getData('log_count', "0");getDataObject(key [, default_object]) {
Retrieve a data value and parse it as JSON to return an object. The default_object parameter will be returned if no data store exists on the model with the specified key.
setData(key, value [, description])
Store a key/value pair against a document. An optional description can be provided for future reference.
setDataObject(key, obj [, description])
Encode an object as JSON and store the value against a document. An optional description can be provided for future reference.
dataStore API
Data stores can be used with any record in ServiceNow using the Unifi dataStore API. We recommend prefixing dataStore with the Unifi scope x_snd_eb to prevent cross-scope issues, e.g. x_snd_eb.dataStore.get(document, "DomainID").
get(document, key [, default_value])
Get a string value from a data store. The default_value parameter will be returned if no data store exists with the specified key.
getAsObject(document, key [, default_object]) {
Retrieve a data value and parse it as JSON to return an object. The default_object parameter will be returned if no data store exists with the specified key.
remove(document, key)
Remove a single data store.
removeAll(document)
Remove all data stores for a document.
set(document, key, value [, description])
Store a key/value pair against a document. An optional description can be provided for future reference.
setFromObject(document, key, obj [, description])
Encode an object as JSON and store the value against a document. An optional description can be provided for future reference.
Was this helpful?
