- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 03:25 AM - edited 03-20-2024 03:26 AM
Hello,
I have an inquiry concerning UI Macros and integration with external systems. We operate a system developed in NodeJS, capable of generating various types of data, including snapshots and chat messages. Once the user finalizes the data generation process, I have the capability to transmit this data back to our ServiceNow instance via REST API calls. The snapshots are uploaded and stored as attachments within ServiceNow, linked to specific incidents.
My question is: Is it feasible to transmit continuous status updates (like a upload progress) from our NodeJS system to ServiceNow and have these updates reflected in the UI Macro, functioning similarly to a Publish/Subscribe (Pub/Sub) model?
I have tried these types of Communication:
- REST Call to a Scripted Rest API firing an event to sys_event queue
- WebSocket Connection from the UI Macro to the external system
Unfortunatly with no luck, can anyone help me on this topic ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 07:29 AM - edited 04-15-2024 07:29 AM
Okay so i found a solution by myself. I am posting this in case anyone needs this information.
So ServiceNow communicates via Websocket between ServiceNow Client and ServiceNow Server. The Websocket connection can be seen when you go to an incident and debug the application with developer tools in chrome or something else. As you can see in the screenshot there is a WebSocket Connection called amb (Asynchronous Message Bus). The ServiceNow Server sends data back and forth in channels via this Bus. On the Client-Site we can subscribe to a Channel with Code like this:
if (incidentGlideRecord.next()) {
var customSysId = incidentGlideRecord.getValue('customTableValue');
var object = 'sys_id=' + customSysId;
var encryptedObject = btoa(object);
var channelName = '/rw/default/somecustomtable/' + encryptedObject;
var channel = amb.getClient().getChannel(channelName);
channel.subscribe(handleMessage);
};
With this you are able to send an upload progress or other live updates to a record and react from the client site accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 07:29 AM - edited 04-15-2024 07:29 AM
Okay so i found a solution by myself. I am posting this in case anyone needs this information.
So ServiceNow communicates via Websocket between ServiceNow Client and ServiceNow Server. The Websocket connection can be seen when you go to an incident and debug the application with developer tools in chrome or something else. As you can see in the screenshot there is a WebSocket Connection called amb (Asynchronous Message Bus). The ServiceNow Server sends data back and forth in channels via this Bus. On the Client-Site we can subscribe to a Channel with Code like this:
if (incidentGlideRecord.next()) {
var customSysId = incidentGlideRecord.getValue('customTableValue');
var object = 'sys_id=' + customSysId;
var encryptedObject = btoa(object);
var channelName = '/rw/default/somecustomtable/' + encryptedObject;
var channel = amb.getClient().getChannel(channelName);
channel.subscribe(handleMessage);
};
With this you are able to send an upload progress or other live updates to a record and react from the client site accordingly.