Does anyone have a good example of using WebSocket in a UI Page?

MG Casey
Mega Sage

I am looking to create a UI Page that updates every 10-15 seconds with new data from the server. In most designs, WebSocket is the right tool for this.

However, I have not seen any examples out there of how to actually implement this in ServiceNow.

Has anyone tried this before?

2 REPLIES 2

Allen Andreas
Administrator
Administrator

Hi,

Here's something sort of along those lines: https://community.servicenow.com/community?id=community_question&sys_id=b62f17321b082410305fea89bd4b...

And then this if there's any action taken: https://community.servicenow.com/community?id=community_question&sys_id=58740f69dbd8dbc01dcaf3231f96...

As you've mentioned, not too common to have this type of request, but that's what I've found. Outside of that, I personally haven't needed to refresh a UI Page in that capacity, but the first option appears most close to what you're wanting to do.

Both...look like it needs some sort of interaction, and won't do it automatically.

Additionally, there's concern from ServiceNow regarding this in cases where the user leaves the page up and it's conducting excessive loads, when it may not be needed, see guidance here (it's in regard to widgets, but the concept could/would possibly be the same): https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0634655

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

I am not talking about reloading the page, but getting new server data displayed on the page.

I can easily do this with a setInterval and REST API, but I know WebSocket is a better way to do this, so I was wanting to see if anyone else has implemented WebSocket before in a UI Page.