Can the Asynchronous Message Bus (AMB) be used directly within an Application (client-subscribe, server-publish)?

David Hubbard
Tera Guru

Hi

I am aware that ServiceNow uses it's Asynchronous Message Bus (AMB) for forum level field updates (record watcher?) and for Mid Server triggering.

But can it be used in a bespoke fashion within an Application, such that a client screen (Workbench panel?) may subscribe to a bespoke topic and a server-side script (on an Event?) can publish to the topic?

I can see there may be alternative ways of doing this (e.g. This community link) but that seems to rely on an external message broker setup (per client instance). 

If it is available for use, can you point me at documentations please?

Thanks

1 ACCEPTED SOLUTION

Hi Rishabh

Very helpful, thanks

I was a bit daunted looking at those scripts but think the key part was it showed how to get the message client from the amb variable. 

   function getChannelRW(table, filter) {
            var t = '/rw/default/' + table + '/' + getFilterString(filter);
            return amb.getClient().getChannel(t);
        }

The key being the "amb.getClient()" rather than "amb"

This change seems to have worked, with a successful subscribe. 

I guess in terms of my initial question the server-side publish part is down to table updates and appropriate subscriptions.

Thanks again for helping me out.    

P.S. For completeness I attach the angular-based reworking of the first link you sent which can work in a UI Script

View solution in original post

13 REPLIES 13

Community Alums
Not applicable

Hello,

 

Well, it's not client-side really, so not a Next Experience Component.

 

I'd like to do this in the backend, server-side, to identify the Assignment Rule that runs on an Incident Assignment Group update (i.e. an update to the Incident record for the assignment_group field) and get its sys_id. 

Basically I need the sys_id of the AR that runs.

 

So far, I haven't found any solution how I can identify this, but thru the Transaction Logs I had ended up here with the AMB discussion you had.

 

Regards,

Lor

Hi

 

Ok understood - I'm thinking that using the AMB for this may be the wrong path for your requirement. 

 

My thinking is that the log entries you are seeing were created when you opened the "sysrule_assignment" in normal UI16. 

 

SN uses AMB internally to show dynamic updates - so if you had two tabs open on a record and updated in one then you would see the update in the other (with a blue icon indicating the field that changed).  Both sessions/tabs would "subscribe" to that record - and see the published update.  My suspicion is the log entry you are seeing is from this.

 

I confess I don't know how "Assignment Rules" are triggered - is there any option to add logging to the script within them to track which one got fired?  just a thought.

 

Community Alums
Not applicable

Hi David,

 

That might be the case probably.

I'm aware of the field change indicator and it might be, that the logs were from when I was on the record, although I specifically updated the Incident to trigger the AR and then pull the logs.

 

Scripting is available on the AR, and it has access to the current object, but that one is pointing to the actual target table (e.g. incident), not the AR itself; hence why I couldn't get the sys_id directly and went on quite different tangents.

 

Nonetheless, thanks for the help and should you come across or remember a way to use the AMB and subscribing in a different manner, please let me know. 🙂

 

Kind regards,

Lori

Rishabh Jha
Mega Guru

Hi David,

Now that your problem has been resolved, would appreciate if you can mark the answer as correct, and close the thread, so that other community members can refer to it as a resolved thread.

Thanks & Regards,

Rishabh Jha

Aavenir (https://www.aavenir.com/)