Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Reacting to events raised in another session?

(1) ShareShare
ReportReport
Posted on by 18
Hello!
 
Here is a rough outline of what we wish to achieve.
 
We have a page-extension, a table and a codeunit exposed as webservice. The page just displays some fields of the table and the webservice acts as an entrypoint for an external system to push some data to the table.
 
Assume I have a user who has the page open in Business Central, they do some work and go to the external platform without closing the page they're currently on. On the external platform they initiate a data sync to the webservice, which will modify some related things and update a timestamp on the table when it finishes.
 
What we would like is to raise an event in the webservice which the page can subscribe to. When the subscriber receives the event a notification is displayed on the already open page of the user.
 
We have already tried to make this work with standard integration events. We even tried reacting to the onValidate() trigger of the timestamp in the table. But it seems that the subscribers cannot pick up events raised in the webservice codeunits. I assume this is because the publisher & subscriber exist in different sessions?
 
Is there another way to achieve this kind of real-time notification on an already open page? We currently solve it by checking if the notification should be displayed when the page fetches the current record it needs to show, but this does not entirely cover our case.
  • Verified answer
    IndraDeMesmaeke Profile Picture
    IndraDeMesmaeke 18 on at
    Reacting to events raised in another session?
    Post creator again!
     
    We followed up on the last idea by creating a recurring page background task which polls the timestamp the last sync happened. The result will be displayed into a status field on the page, thereby achieving our wanted 'real-time' informing of the user.
    We combine it with a standard notification shown when the page opens.
     
    Hope this can help someone else looking to achieve something similar! 
  • IndraDeMesmaeke Profile Picture
    IndraDeMesmaeke 18 on at
    Reacting to events raised in another session?
    Creator of the post here again.
     
    We've been thinking about another approach. Since we keep a timestamp of when the last sync happened by the external system...
     
    Would it be an acceptable approach to create a page background task which polls the table every X seconds. 
    Either we prevent the background task from finishing and enqueue it only once, so it keeps polling or we reschedule the task every time it finishes a poll.
     
    This way the page has the 'real-time' notifications (or close enough, with an acceptable polling timeout), and the page background task will not impact the user as it lives in another thread.

    The downside I see is that if a user hides the notification it will keep popping up if the display conditions are met. Which is not the best UX.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,759 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,468 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans