Hi All,
I added User group field in create alert rule form.
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
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
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
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
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.
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156