Thursday, February 23, 2017

Alert Sample Code in Ax 2012

static void create_alert(Args _args)
{
        EventNotificationSource                source;
        EventNotification                                event = EventNotification::construct(EventNotificationSource::Sync);
        EventInboxId                            inboxid;
        ;
        event.parmRecord(_record);
        event.parmUserId(curuserid());
        event.parmDataSourceName('ledgerjournaltable');
        event.parmMenuFunction(new MenuFunction('LedgerJournalTable5', MenuItemType::Display));
        event.parmSubject('Customer Changed');
        event.parmMessage('Customer has changed, please verify');
        inboxid = event.create();
}

static void AlertTestEvent(Args _args)
{
    EventInbox inbox;
    ;
    inbox.initValue();
    inbox.ShowPopup = NoYes::Yes;
    inbox.Subject = "This is the Alert subject";
    inbox.Message = "This is the Alert message";
    inbox.AlertedFor = "This alert is just information no links are available";
    inbox.SendEmail = false;
    inbox.UserId = curuserid();
    inbox.TypeId = classnum(EventType);

    //inbox.AlertTableId = tablenum(Address);
    //inbox.AlertFieldId = fieldnum(Address, Name);
    //inbox.TypeTrigger = EventTypeTrigger::FieldChanged;
    inbox.CompanyId = curext();
    inbox.InboxId = EventInbox::nextEventId();
    inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime();
    inbox.insert();
}
static void AlertTest(Args _args)
{
    EventNotificationSync   alert;
    MenuFunction            MenuFunction;
    str                     dataSourceName;
    Name                    _subject ="Entered is greater than Current Stock Onhand Qty";
    Name                _bodyMsg = "Ensure you are entered Qty is greater than Stock on Hand Qty";
    UserId                  _user;
    ; 
    _user                = curUserId();       
    //dataSourceName  =   tablestr(PurchLine);
    //MenuFunction    =   new MenuFunction(menuitemdisplaystr(PurchTable), MenuItemType::Display);
    alert           =   EventNotificationsync::newInfo(_subject,
                                        _bodyMsg,
                                        _bodyMsg,
                                        NoYes::NO);
    alert.parmUserId(_user);       
    alert.create();
}

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...