LogoLogo
AboutSupport
4.3
4.3
  • Unifi User Documentation
  • Install
    • Release Notes
      • Unifi 4.3 Release Notes
      • Unifi 4.2 Release Notes
      • Unifi 4.1 Release Notes
      • Unifi 4.0 Release Notes
      • Unifi 3.1 Release Notes
      • Unifi 3.0 Release Notes
      • Unifi 2.2 Release Notes
      • Unifi 2.1 Release Notes
      • Unifi 2.0 Release Notes
    • Install or Upgrade
      • Global Utility
      • Hotfix
  • Configure
    • Integration Designer
    • Processes
    • Integrations
    • Connections
    • Messages
    • Message Scripts
    • Fields
    • Field Maps
    • Response Actions
    • Event Actions
    • Datasets
      • Create a New Dataset
      • Dataset Extras
    • Polling
      • Pollers
      • Poll Processors
    • Administration
      • Activity Logs
      • Data Stores
      • Properties
      • Scheduled Scripts
      • System Logs
    • Attachments
      • Extracting Attachments
      • Fetching Attachments
      • Embedded Attachments
    • Scripting
      • Snippets
      • Variables
    • Documentation
    • How to guides
      • How to Handle Attachments
        • Message
        • Scripted REST Resource
        • Test AddAttachment
      • How to Manually Close a Bond
      • How to Poll for Large Response Payloads
      • How to Setup an OAuth Connection
        • Identity Provider Instance
        • Identity Consumer Instance
        • OAuth Refresh Token Job
      • How to Setup Heartbeat Messages
  • Deploy
    • Package
    • Instance Clone
  • Operate
    • Bonding
      • Bonds
      • Bonded Attachments
    • Transport
      • Snapshots
      • Transactions
      • Stages
      • HTTP Requests
      • Dataset Requests
      • Poll Requests
    • Error Handling
      • Integration Pause and Resume
      • Integration Repair
      • Request Retry
      • Transaction & Request Replay
      • Transaction Ignore
  • Test
    • Overview
    • Integration Test
    • Test Scenario
    • Test Scenario Data
    • Test Result
    • Test Scenario Result
    • Generating Tests
    • Running Tests
    • Exploring Results
  • Integration Guides
    • Outbound Incident Guide
      • Getting Started
      • Process
      • Integration
      • Connection
      • Create Scenario
        • CreateIncidentResponse Message
        • CreateIncidentResponse Fields
        • CreateIncident Message
        • CreateIncident Fields
        • Trigger
        • Test CreateIncident
      • Update Scenario
        • Response Message
        • UpdateIncident Message
        • UpdateIncident Fields
        • Test UpdateIncident
      • Resolve Scenario
        • ResolveIncident Message
        • ResolveIncident Fields
        • Test ResolveIncident
      • Build - Integration Level
      • Conclusion
    • Bidirectional Asynchronous Incident Guide
      • Getting Started
      • Process
      • Web Service
      • Integration
      • Connection
      • Create Scenario
        • Response Message
        • CreateIncidentReceipt Message
        • CreateIncidentReceipt Fields
        • CreateIncident Message
        • CreateIncident Fields
        • Trigger
        • Test CreateIncident
      • Update Scenario
        • Receipt Message
        • UpdateIncident Message
        • UpdateIncident Fields
        • Test UpdateIncident
      • Resolve Scenario
        • ResolveIncident Message
        • ResolveIncident Fields
        • Test ResolveIncident
      • Build - Integration Level
      • Build the Other Half
        • Move the Integration
        • Reconfigure the Connections
      • Conclusion
    • Incident Update Poller Guide
      • Polling
        • Poll Processor
        • Poller
      • Inbound Message
        • UpdateIncidentInbound Message
        • UpdateIncidentInbound Fields
      • Message Identification
      • Bond Identification
        • Edit Incident Form
        • Edit CreateIncident Message
      • Test Update Poll
      • Conclusion
    • Incident Multiple Message Poller Guide
      • Polling
        • Poll Processor
        • Poller
      • Inbound Messages
        • ResolveIncidentInbound Message
        • ResolveIncidentInbound Fields
      • Testing
        • Test UpdateIncidentInbound
        • Test ResolveIncidentInbound
      • Conclusion
    • Incident Create Poller Guide
      • Polling
        • Connection Variables
        • Poll Processor
        • Poller
      • Messages
        • CreateIncidentInboundReceipt Message
        • CreateIncidentInboundReceipt Fields
        • CreateIncidentInbound Message
        • CreateIncidentInbound Fields
      • Build - Integration Level
      • Test Create Poll
      • Conclusion
    • Incident Parent and Child Poller Guide
      • Polling
        • Connection Variables
        • Child Poll Processor
        • Child Poller
        • Parent Poll Processor
        • Parent Poller
      • Inbound Messages
      • Testing
        • Test UpdateIncidentInbound
        • Test ResolveIncidentInbound
      • Conclusion
    • Incident Attachment Poller Guide
      • Polling
        • Connection Variables
        • Edit Endpoint URLs
        • Get Attachment Poll Processor
        • Get Attachment Poller
        • Select Attachments Poll Processor
        • Select Attachments Poller
        • Edit Child Poll Processor
        • Edit Child Update Poller
      • Messages
        • AddAttachmentInbound Message
      • Testing
        • Test Outbound Scenarios
        • Test CreateIncidentInbound
        • Test UpdateIncidentInbound
        • Test ResolveIncidentInbound
        • Test AddAttachmentInbound
      • Conclusion
  • Troubleshooting
    • Attachments
      • Inbound SOAP/Base64 attachments stopped working
      • New record attachments are not sent from Portal
      • Special characters in attachment file names
    • Datasets
    • Development
      • Bonding to existing records
      • Copying an existing Unifi trigger rule doesn't work
      • Duplicate messages being sent
      • Deleted records are not packaged
      • Multipart Form Data
      • Undefined error when building an integration
    • Diagnostic
    • Installation
      • Latest version of Unifi not accessible
    • Integration Responses
      • Transaction has been processed already
      • Initiating transaction not found for inbound receipt
      • Message has already been processed
      • Message ID not found
      • Message is not valid for this bond
      • Message name not recognised
      • No retry for requests with 401 response
      • Unable to identify message name from request
    • Other
      • Dynamic stage does not render
      • Duplicate bonds on Request integrations
    • Self-test
  • About
    • Quick Tour
    • Roles
    • Supported Features
    • Application Modules
    • Data Model
    • Transport Data Flow
Powered by GitBook
On this page
  • Usage
  • Built-in Examples
  • Storing Strings
  • Storing Objects
  • dataStore API
  • get(document, key [, default_value])
  • getAsObject(document, key [, default_object]) {
  • remove(document, key)
  • removeAll(document)
  • set(document, key, value [, description])
  • setFromObject(document, key, obj [, description])

Was this helpful?

Export as PDF
  1. Configure
  2. Administration

Data Stores

A Data Store is simply a key-value pair stored in the database that is available to all records in the system.

PreviousActivity LogsNextProperties

Last updated 3 months ago

Was this helpful?

Usage

Use Data Stores to easily make variables persistent and retrievable.

Data Stores are used primarily in and 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

Built-in Examples

All Unifi model objects have data store built in. Calling these methods will read/write data stores on the record the object is representing. Note: not all objects available in Unifi scripts are Unifi model objects.

Storing Strings

Use getData and setData to work with simple string-like data.

// Store the current log count
var log_count = bond.getData('log_count');
bond.setData('log_count', parseInt(log_count, 10) + 1)

Storing Objects

You can also work with objects just as easily by using getDataObject and setDataObject. These functions automatically take care of encoding the object for database storage and decoding it for JavaScript usage again.

// Store the logs that have been seen in an array
var logs_seen = bond.getDataObject('logs_seen'); // [1375, 1399, 1748]
logs_seen.push(2140);
bond.setDataObject('logs_seen', logs_seen);

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.

x_snd_eb.dataStore.get(current, "MyStr");

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.

x_snd_eb.dataStore.getAsObject(current, "MyObj");

remove(document, key)

Remove a single data store.

x_snd_eb.dataStore.remove(current, "MyStr");

removeAll(document)

Remove all data stores for a document.

x_snd_eb.dataStore.remove(current);

set(document, key, value [, description])

Store a key/value pair against a document. An optional description can be provided for future reference.

x_snd_eb.dataStore.set(current, "MyStr", "My value", "This is my value");

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.

x_snd_eb.dataStore.set(current, "MyObj", {foo: "bar"}, "Hello world!");
Message Scripts
Poll Processor