Monday, 9 November 2015

Send Workflow Notification / Popup / Alert using X++ [AX 2012]

Hi guys,

Recently I was a requirement to create customized Sales Order Discount Approval workflow. There is  a lot of scenario to mapping  the process.
In this session I am describing  how to send notification or alert to respective User Group / Users as bellow job 

// Send notification or Alert
static void SendAlert_Notication(Args _args)
{
    Dialog          dialog;
    DialogGroup     dialogGroup;
    DialogField     dialogfield;
    DialogBox       dialogBox;    
    
    EventInbox      EventInbox;
    UserGroupList   userGroupList;
    SalesLine       updateSalesLine;
    UserGroupId     groupId;     
    SalesLine       salesLine;
    ;    
    //Dialog call
    dialog= new dialog("Sales Price Discount Approval");
    dialogGroup= dialog.addGroup("Comment");
    dialogfield= dialog.addField(extendedTypeStr(Ale_Comment));
    if (dialog.run())
    dialogfield.value();
    

    while select userId from userGroupList
    where userGroupList.groupId == "Admin"
    {
        while select SysUserInfo order by SysUserInfo.Id where SysUserInfo.Id  == userGroupList.userId 
        {
            EventInbox.InboxId                      =   EventInbox::nextEventId();
            EventInbox.CompanyId                    =   SalesLine.dataAreaId;
            EventInbox.AlertTableId                 =   359;
            EventInbox.AlertCreatedDateTime         =   DateTimeUtil::utcNow();
            EventInbox.ParentTableId                =   359;
            EventInbox.IsRead                       =   NOYES::No;
            EventInbox.Subject                      =   "SalesOrder Discount Approval";
            EventInbox.AlertedFor                   =   dialogfield.value();
            EventInbox.UserId                       =   SysUserInfo.Id;
            EventInbox.ShowPopup                    =   NOYES::Yes;
            EventInbox.Visible                      =   NOYES::Yes;
            EventInbox.Message                      =   dialogfield.value();
        }
    }
    
}    

Hope it will help...


Happy DAXing :-)


No comments:

Post a Comment

Import General journal from excel in D365 F&O

 Hi Guys, Import General journal from excel in D365 F&O Code:  using System.IO; using OfficeOpenXml; using OfficeOpenXml.ExcelPackage; u...