Send message or alert to all online users

In Axapta 2.5 or 3.0, there is a standard function to send message to all online users. But it has been taken away after AX 4.0. However you still do this by some codes:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
static void sendAlertToOnlineUsers(Args _args)
{
    EventInbox        inbox;
    EventInboxId      inboxId;
    SysClientSessions sessions;
    ;
 
    while select sessions
        where sessions.Status == SessionState::Running
    {
        inboxId = EventInbox::nextEventId();
 
        inbox.initValue();
        inbox.ShowPopup            = NoYes::Yes;
        inbox.Subject              = "GIT TESTING ALERT MESSAGE";
        inbox.Message              = "HELLO?";
        inbox.SendEmail            = false;
        inbox.UserId               = sessions.userId;
        inbox.InboxId              = inboxId;
        inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime();
        inbox.insert();
    }
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.