Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Which class is triggered during Alerts notifications in AX 2012

Posted on by 692

Hi All,

I added User group field in create alert rule form.

2017_2D00_04_2D00_13-_2800_2_2900_.png

I want to send alert notifications to all users in above usergroup.

To achieve this in which class do i need to implement my code.

I tried in 

EventNotification, EventNotificationSync Classess create method.

but it won't be useful.

Can anyone guide me correct direction. for achieving the above requirement

Thanks,

Krishna

*This post is locked for comments

  • Norseman Profile Picture
    Norseman 55 on at
    RE: Which class is triggered during Alerts notifications in AX 2012

    Krishna,

    I have exactly similar requirement by my user. The above code doesn't compile, as there is no Id in EventRule table. Also how did you call from EventActionAlert's execute method? Could you please post more details? I really appreciate your time.

    Thanks,

    Vivek

  • Verified answer
    gsbsrk b Profile Picture
    gsbsrk b 692 on at
    RE: Which class is triggered during Alerts notifications in AX 2012

    Hi All,

    EventActionAlert is the class to create alert notifications in AX 2012 R2

    I just put my code in a new method and i called that method in Execute method.

    Thanks guys

    Krishna

  • gsbsrk b Profile Picture
    gsbsrk b 692 on at
    RE: Which class is triggered during Alerts notifications in AX 2012

    Thanks  Vilmos and Zain.

    public EventInboxId create(EventInbox          inbox)

    {

       EventInbox              eventInbox;

       EventInboxData          eventInboxData,eventInboxData1;

       EventInboxId            inboxId;

       EventInbox          _inbox = EventInbox::find(inbox.InboxId);

       EventInboxData      _inboxData = EventInboxData::find(inbox.InboxId,EventInboxDataType::Context);

       EventInboxData      _inboxData1 = EventInboxData::find(inbox.InboxId,EventInboxDataType::TypeData);

       EventRule               eventRule = EventRule::find(_inbox.RuleId);

       UserGroupList           userGroupList;

       if(eventRule.id)

       {

           while select userGroupList where userGroupList.groupId == eventRule.id &&

              userGroupList.userId != _inbox.UserId

           {

               inboxId                             = EventInbox::nextEventId();

               eventInbox.InboxId                  = inboxId;

               eventInbox.ShowPopup                = NoYes::Yes;

               eventInbox.Subject                  = _inbox.Subject;

               eventInbox.Message                  = _inbox.Message;

               eventInbox.AlertedFor               = _inbox.AlertedFor;

               eventInbox.SendEmail                = _inbox.SendEmail;

               eventInbox.UserId                   = userGroupList.userId;

               eventInbox.RuleId                   = _inbox.RuleId;

               eventInbox.TypeId                   = _inbox.TypeId;

               eventInbox.ParentTableId            = _inbox.ParentTableId;

               eventInbox.AlertTableId             = _inbox.AlertTableId;

               eventInbox.AlertFieldId             = _inbox.AlertFieldId;

               eventInbox.AlertFieldLabel          = _inbox.AlertFieldLabel;

               eventInbox.GlobalRule               = _inbox.GlobalRule;

               eventInbox.TypeTrigger              = _inbox.TypeTrigger;

               eventInbox.CompanyId                = _inbox.CompanyId;

               eventInbox.AlertCreatedDateTime     = _inbox.AlertCreatedDateTime;

               eventInbox.insert();

               eventInboxData.InboxId = inboxId;

               eventInboxData.DataType = EventInboxDataType::Context;

               eventInboxData.Data = _inboxData.Data;

               eventInboxData.insert();

               eventInboxData1.InboxId = inboxId;

               eventInboxData1.DataType = EventInboxDataType::TypeData;

               eventInboxData1.Data = _inboxData1.Data;

               eventInboxData1.insert();

           }

       }

       return inbox.InboxId;

    }

    This is my code

    I want alert rule and  Event inbox info based on that i can insert alert notification to users in that particular user group.

    For Ex Employee status filed i create alert rule.

    If employee status got changed i need to send alert notifications.

    Please guide me in right direction.

    Thanks,

    Krishna

  • Suggested answer
    Zain Bokhari Profile Picture
    Zain Bokhari 3,208 on at
    RE: Which class is triggered during Alerts notifications in AX 2012

    Hi Krishna,

    Instead of trying to change the implementation of an existing class why don't you write a batch job and implement your logic there with the help of EventNotification class.

    I once implemented a similar code that sent users in a particular group notifications based on required logic. 

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: Which class is triggered during Alerts notifications in AX 2012

    You could have used cross-references to find it yourself easily. The table where the alert is originally inserted is EventCUD, from which the alerts are generated and sent to the users' EventInbox.

    Take a look at EventJobCUDTask.run() and .runCudEventsForUser(), which is the change based alerts batch for an idea.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans