openFrameAPI - Client
The openFrameAPI provides methods that interact with OpenFrame. OpenFrame is an omni-present frame that communication partners can use to integrate their systems into the ServiceNow platform.
One of the core requirements is the ability to connect and serve code from different domains that can connect seamlessly with partner subsystems. This cross domain connection is required to keep connections and callbacks registered into communication systems without any cross domain issues.
openFrameAPI - getAWAAgentPresence(String success, String failure)
Returns the logged in agent’s current presence state.
| Name | Type | Description |
|---|---|---|
| success | String | If the method is successful, name of the callback function to invoke. |
| failure | String | If the method fails, name of the callback function to invoke. |
| Type | Description |
|---|---|
| presence | Results passed to the success callback function by the openFrame infrastructure. Data type: Object |
| presence.available | Flag that indicates whether the associated agent is available. Valid values:
Data type: Boolean |
| presence.channels | List of available channels of communication with the agent. Data type: Array of Objects
|
| presence.channels.available | Flag that indicates whether the channel is available. Valid values:
Data type Boolean |
| presence.channels.name | Name of the channel, such as Chat or Phone. Data type: String |
| presence.channels.restrict_update | Flag that indicates whether the user can restrict updates to the channel. Valid values:
Data type Boolean |
| presence.channels.service_channel_type | Type of the service channel. Data type: String |
| presence.channels.sys_id | Sys_id of the channel record. Located in the Service Channels [awa_service_channel] table. Data type: String |
| presence.name | Name of the agent's presence state. Data type: String |
| presence.sys_id | Sys_id of the presence state record. Located in the Presence States [awa_presence_state] table. Data type: String |
The following code exapmle shows how to call this method.
function failure(data)
{
console.log("failure: " + JSON.stringify(data));
}
function success(data)
{
console.log("success: " + JSON.stringify(data));
}
openFrameAPI.getAWAAgentPresence(success, failure)
Response to success callback function:
success: {
"presence": {
"name": "Available",
"sys_id": "0b10223c57a313005baaaa65ef94f970",
"available": true,
"channels": [
{
"name": "Chat",
"available": true,
"sys_id": "27f675e3739713004a905ee515f6a7c3",
"restrict_update": false,
"service_channel_type": "chat"
}
]
}
}
openFrameAPI - hide()
Hides the OpenFrame in the TopFrame.
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| void |
openFrameAPI.hide()
openFrameAPI - init(Object config, function successCallback, function failureCallback)
Initializes OpenFrame. This must be the first method that you call.
This method initializes communication to TopFrame and initializes any visual elements passed in the config parameter.
| Name | Type | Description |
|---|---|---|
| config | Object | Name-value pairs to use during the initialization process. Possible keys: All keys are optional. Pass an empty object if you don't want to set these key-value pairs.
|
| successCallback | function | Name of the callback function to use if the init method succeeds. The OpenFrame configuration stored in the system is passed as a parameter to the callback function. |
| failureCallback | function | Name of the callback function to use if the init method fails. |
| Type | Description |
|---|---|
| void |
var config = {
height: 300,
width: 200
}
function handleCommunicationEvent(context) {
console.log("Communication from Topframe", context);
}
function initSuccess(snConfig) {
console.log("openframe configuration", snConfig);
//register for communication event from TopFrame
openFrameAPI.subscribe(openFrameAPI.EVENTS.COMMUNICATION_EVENT,
handleCommunicationEvent);
}
function initFailure(error) {
console.log("OpenFrame init failed...", error);
}
openFrameAPI.init(config, initSuccess, initFailure);
openFrameAPI - isVisible(function callback)
Checks to see if the OpenFrame is visible in the TopFrame.
| Name | Type | Description |
|---|---|---|
| callback | function | The callback function receives a parameter with a value of true or false. True if OpenFrame is visible and false if not visible. |
| Type | Description |
|---|---|
| void |
function callback(isVisible) {
console.log(isVisible)
}
openFrameAPI.isVisible(callback)
openFrameAPI - openCustomURL(String details)
Opens a custom URL in the UI16 interface.
| Name | Type | Description |
|---|---|---|
| Url | String | Text of the custom URL. Maximum size: 2083 characters |
| Type | Description |
|---|---|
| void |
openFrameAPI.openCustomURL('10_cool_things.do');
openFrameAPI - openServiceNowForm(Object details)
Opens a form URL.
- In the platform interface, this API opens a form URL in TopFrame.
- For Agent Workspace, this API supports interaction tab management. In Agent Workspace, an interaction record opens in a parent tab and the specified entity record opens in a child tab under the interaction tab.
| Name | Type | Description |
|---|---|---|
| details | Object | Key-value pairs that identify the form URL to open.
|
| details.entity | String | Table or entity name. |
| details.interaction_sys_id | String | Optional. Sys_id of the interaction record to open as parent tab in Agent Workspace. Note: In the platform interface the
interaction_sys_id is ignored. |
| details.query | String | Query to identify the record to open, such as:
query:'sys_id=<record_sys_id>'. |
| Type | Description |
|---|---|
| void |
The following example shows basic usage in platform:
openFrameAPI.openServiceNowForm({entity:'customer_account',
query:'sys_id=447832786f0331003b3c498f5d3ee452', 'interaction_sys_id':'3be092313b711300758ce9b534efc4dd'});
The following example shows how to use the query parameter to create a new record with data provided in the form by using sysparm_query and an encoded query to populate the first and last name fields in Workspace:
openFrameAPI.openServiceNowForm({ entity: 'sys_user',
query: 'sys_id=-1&sysparm_query=first_name=Ivan^last_name=Greggor' });
openFrameAPI - openServiceNowFormwithChildTab()
Opens a ServiceNow form with a child tab if invoked in a workspace or opens an entity if invoked in the UI16 interface.
| Name | Type | Description |
|---|---|---|
| openServiceNowFormwithChildTab | Object | Defines if the API opens a ServiceNow form with a child tab if invoked in a workspace or opens an entity if invoked in the UI16 interface. |
| openServiceNowFormwithChildTab.entity | String | Name of the table that contains the record to open. |
| openServiceNowFormwithChildTab.sys_id | String | Sys_id of the record to open. |
| openServiceNowFormwithChildTab.parent_entity | String | Name of the table to open as a parent tab. |
| openServiceNowFormwithChildTab.parent_entity_sys_id | String | Sys_id of the parent record to open. |
| Type | Description |
|---|---|
| None |
The following example opens the parent entity as a parent tab on a configured workspace, or opens just the entity if invoked in UI16.
openFrameAPI.openServiceNowFormwithChildTab({
entity: "customer_account",
sys_id: "447832786f0331003b3c498f5d3ee452",
parent_entity: "interaction",
parent_entity_sys_id: "3be092313b711300758ce9b534efc4dd"
});
openFrameAPI - openServiceNowList(Object details)
Opens a list URL in the UI16 interface.
| Name | Type | Description |
|---|---|---|
| details | Object | Key value pairs that describe the content to use when opening the list URL. Valid values:
|
| Type | Description |
|---|---|
| void |
openFrameAPI.openServiceNowList({entity:'case', query:'active=true'});
openFrameAPI - setFrameMode(mode)
Sets the OpenFrame mode.
- Sets the appropriate icon in the header: collapse or expand
- Raises the relevant event for CTI:
- openFrameAPI.EVENTS.COLLAPSE
- openFrameAPI.EVENTS.EXPAND
| Name | Type | Description |
|---|---|---|
| Mode | String | Set OpenFrame Mode. Enumerated options:
|
| Type | Description |
|---|---|
| void |
openFrameAPI.setFrameMode(openFrameAPI.FRAME_MODE.COLLAPSE);
openFrameAPI - setHeight(height)
Sets the OpenFrame height.
| Name | Type | Description |
|---|---|---|
| Height | Number | Height in pixels |
| Type | Description |
|---|---|
| void |
openFrameAPI.setHeight(100);
openFrameAPI - setIcons(Array icons)
Defines icons in the OpenFrame header that are placed next to the close icon.
| Name | Type | Description |
|---|---|---|
| icons | Array of objects | A list of icon configurations, where each icon configuration is an object with key values imageURL, imageTitle, and any other needed context. Maximum size: Icons can be a maximum of 16x16 pixels. Larger images are automatically adjusted to this maximum. |
| Type | Description |
|---|---|
| void |
openFrameAPI.setIcons([{imageURL:'https://mydomian.com/image/mute.png',
imageTitle:'mute', id:101}, {imageURL:'https://mydomian.com/image/hold.png',
imageTitle:'hold', id:102}]);
openFrameAPI - setPresenceIndicator(presence)
Sets the presence indicator to display agent availability in a workspace.
For more information on configuring OpenFrame, refer to Create an OpenFrame configuration
| Name | Type | Description |
|---|---|---|
| state | String | Presence state of the agent. Default states:
You can also specify custom states. |
| color | String | Presence indicator color on workspace. Supported colors:
|
| Type | Description |
|---|---|
| void |
openframeAPI.setPresenceIndicator('Available', 'green');
openFrameAPI - setSize(Number width, Number height)
Sets the OpenFrame size.
| Name | Type | Description |
|---|---|---|
| width | Number | Should be greater than zero. |
| height | Number | Should be greater than zero. |
| Type | Description |
|---|---|
| void |
openFrameAPI.setSize(300, 370);
openFrameAPI - setSubtitle(String subTitle)
Sets the OpenFrame subtitle.
| Name | Type | Description |
|---|---|---|
| subTitle | String | A string of 256 or fewer characters. |
| Type | Description |
|---|---|
| void |
openFrameAPI.setSubtitle('+18888888888');
openFrameAPI - setTitle(String title)
Sets the OpenFrame title.
| Name | Type | Description |
|---|---|---|
| title | String | A string of 256 or fewer characters. |
| Type | Description |
|---|---|
| void |
openFrameAPI.setTitle('Incoming Call');
openFrameAPI - setTitleIcon(Object icon)
Sets the OpenFrame's title icon.
| Name | Type | Description |
|---|---|---|
| icon | Object | Object of key value pairs. Keys include imageURL, imageTitle, and any other context needed. Maximum size: Icons can be a maximum of 16x16 pixels. Larger images are automatically adjusted to this maximum. |
| Type | Description |
|---|---|
| void |
openFrameAPI.setTitleIcon({imageURL:'/my/image/path.png', imageTitle:'mute', id:101});
openFrameAPI.setTitleIcon({imageURL:'https://mydomian.com/image/path.png',
imageTitle:'mute', id:101});
openFrameAPI - setWidth(width)
Sets the OpenFrame width.
| Name | Type | Description |
|---|---|---|
| Width | Number | Width in pixels |
| Type | Description |
|---|---|
| void |
openFrameAPI.setWidth(100);
openFrameAPI - show()
Makes the OpenFrame visible in the TopFrame.
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| void |
openFrameAPI.show()
openFrameAPI - subscribe(openFrameAPIEVENT event, function eventCallback)
Subscribes to a specified event.
| Name | Type | Description |
|---|---|---|
| event | openFrameAPIEVENT | The event to subscribe to:
|
| eventCallback | function | Function to call when the specified event occurs. |
| Type | Description |
|---|---|
| results | Most event subscriptions have no return values. The event subscriptions that do return values are described in the following table entries. |
| openframe_awa_agent_presence | In AWA, the openframe_awa_agent_presence event returns the presence object:presence: Information about an agent's current presence state and channel.
|
| openframe_awa_workitem_accepted and openframe_awa_workitem_offered | In AWA, the openframe_awa_workitem_accepted and openframe_awa_workitem_offered events return the workItem object:workItem: Information about the work item that is associated with the event.
|
| openframe_awa_workitem_rejected | In AWA, the openframe_awa_workitem_rejected event returns the workItem object:workItem: Information about the work item that is associated with the event.
|
The following code example shows how to call this method for an openframe_awa_agent_presence event.
function handleIconClick(context) {
console.log("Icon was clicked", context);
}
openFrameAPI.subscribe(openFrameAPI.events.openframe_awa_agent_presence, handleIconClick);
Output:
// Sample presence object output
// openframe_awa_agent_presence event only
{
"result":{
"presence":{
"name":"Available",
"sys_id":"27f675e3739713004a905ee515f6a7c3",
"available":true,
"channels":[
{
"name":"Chat",
"available":true,
"sys_id":"36f675e4239713124a905fe515f6a832",
"restrict_update":false
},
{
"name":"Phone",
"available":true,
"sys_id":"9378a530a1820610f809018efd9bc01e",
"restrict_update":false
}
]
}
}
}
The following code example shows how to call this method for an openframe_awa_workitem_accepted event.
function handleIconClick(context) {
console.log("Icon was clicked", context);
}
openFrameAPI.subscribe(openFrameAPI.events.openframe_awa_workitem_accepted, handleIconClick);
Output:
// Sample workItem object output
// openframe_awa_workitem_accepted event only
{
"result": {
"workItem": {
"sys_id": "14c86c40a1650610f87701807d9bc0be",
"size": 1,
"serviceChannel": {
"name": "Chat",
"sys_id": "27f675e3739713004a905ee515f6a7c3"
},
"document": {
"sys_id": "aa582040a1650610f87701807d9bc076",
"table": "interaction"
},
"previousWorkItem": "7c78a440a1650610f87701807d9bc02b",
"isQueueTransferred": true,
"isAutoAccepted": true
}
}
}
The following code example shows how to call this method for an openframe_awa_workitem_rejected event.
function handleIconClick(context) {
console.log("Icon was clicked", context);
}
openFrameAPI.subscribe(openFrameAPI.events.openframe_awa_workitem_rejected, handleIconClick);
Output:
// Sample workItem object output
// openframe_awa_workitem_rejected event only
{
"payload": {
"workItem": {
"sys_id": "2c3bdc4824250610f8775e73b116f8de",
"size": "1",
"serviceChannel": {
"name": "Chat",
"sysID": "27f675e3739713004a905ee515f6a7c3"
},
"document": {
"sys_id": "cf0a180824250610f8775e73b116f80c",
"table": "interaction"
},
"rejection": {
"reason": "Busy",
"sys_id": "4e93fa29b38023002e7b6e5f26a8dc20"
},
"previousWorkItem": "831b9c4824250610f8775e73b116f841",
"isQueueTransferred": true
}
}
}
openFrameAPI - version()
Returns the OpenFrame API version.
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| String | The OpenFrame API version |
var version = openFrameAPI.version();
console.log("API version " + version);