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:

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();
    }
}

Comments

Popular posts from this blog

Post packing slip of sales order in X++