Pages

November 08, 2012

Create Alert using X++ codes

Create Alert using X++ codes


Sometimes Infolog message is not sufficient enough for prompting information to users. It is possible to create alert message using code as an alternative. It is fairly simple to create alert message manually by just inserting a new record in EventTable where all the alert messages are stored. Below is a code snippet for creating alert using code in AX 2009.
Try following code......





static void CreateAlertUsingCode(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();
}
 
- Harry

No comments:

Post a Comment

Thanks