Thursday, 9 September 2021

Send notification/ alert using X++ in Ax 2012

 Here is the X++ code to send the custom notification alert in Ax 2012.

static void SendNotificationAlert(Args _args)
{
    EventInbox  EventInbox,inbox;
    EventInboxData  eventInboxData;
    SysUserInfo SysUserInfo;
    int64 inboxId;
    ;

    ttsBegin;
        select SysUserInfo 
            order by SysUserInfo.Id 
            where SysUserInfo.Id== curUserId();

    { 
        select maxof(inboxId) from inbox;
        inboxId = EventInbox::nextEventId();
        EventInbox.CompanyId              =   curext();
        EventInbox.AlertTableId           =   212;
        EventInbox.AlertCreatedDateTime   =   DateTimeUtil::utcNow();
        EventInbox.ParentTableId          =   212;
        EventInbox.IsRead                 =   NOYES::No;
        EventInbox.Subject                =   "Notification Received ..";
        EventInbox.AlertedFor             =   "Notification Testing .. "; 
        EventInbox.UserId                 =   SysUserInfo.Id;
        EventInbox.ShowPopup              =   NOYES::Yes;
        EventInbox.Visible                =   NOYES::Yes;
        EventInbox.Message                =   'Notification Received ..!!';
        EventInbox.NotificationType       =   EventNotificationType::Information;
        EventInbox.insert();

        eventInboxData.DataType           =  EventInboxDataType::Context;
        eventInboxData.InboxId            =  inboxId;
        eventInboxData.insert();

        info("Notification sent");

    }

    ttsCommit;
}

2 comments:

  1. Wonderful Article. Thanks for sharing this post
    Microsoft Dynamics 365 Training In Hyderabad

    ReplyDelete

Difference Between Edit And Display Method in Ax

Display Method: The display method means that the method’s return value is being displayed on a form or a report.  This value is fixed and c...