web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Custom fields on email alert templates AX 2012

(0) ShareShare
ReportReport
Posted on by 634

Hi,

I am trying to create an email alert when the credit limit in customer master has been changed. 

This is how my email template looks like :

%subject% in company '%company%'

Event occurred on : %occurred%

Record where event occurred : %for%

Data changed : %data%

This is a system generated email. Please do not reply to this.

Here my requirement is to display the currency from the customer master and the user who changed the credit limit. how can I achieve it ?

also need to know whether I can bring other fields in the alert email (Could be a display method) which is not in customer table directly. 

Thanks 

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    Check createEmailParameterMap method  in EventActionEmail class. There you will see parameterMap it maps placeholders to data. Usung something like this

    record = SysDictTable::findFromKeyData(inbox.AlertTableId,inbox.KeyFieldData());

    you can get source record and add values from the record to new placeholders you need.

  • D365  beginner Profile Picture
    634 on at

    Hi Ievgen,

    Thanks for the reply, Is there any sample threads which shows step by step customization for the same ? I couldn't succeed with it.

  • Mea_ Profile Picture
    60,284 on at

    Have not seen one. So just explain what you've done and we will build it here. 

  • D365  beginner Profile Picture
    634 on at

    Hi Ievgen,

    I really have no idea how can I add the code here to retrieve the the fields for particular record. for example Currency as per the requirement said.  

    Map createEmailParameterMap(EventInbox _inbox, EventType _eventType, EventRule _eventRule)
    {
    Map parameterMap = new Map(Types::String,Types::String);
    SqlSystem sqlSystem = new SqlSystem();

    SysDictClass dictClass = new SysDictClass(_inbox.TypeId);
    SysDictTable dictTable = new SysDictTable(_inbox.AlertTableId);

    SysDictField dictField = new SysDictField(_inbox.AlertTableId,_inbox.AlertFieldId);
    SysDictEnum dictEnum;

    str event;
    str table;
    str data;


    str previousValue;
    str currentValue;

    str drillDownGroup;
    ;

    event = EventInbox::buildSubject(_inbox);

    table = dictTable.label();

    if(SysDictClass::isEqualOrSuperclass(_inbox.TypeId, classnum(EventTypeCUD))&& _inbox.TypeTrigger == EventTypeTrigger::FieldChanged)
    {
    if (dictField.enumId() == 0)
    {
    if (dictField.isSurrogateForeignKey())
    {
    previousValue = EventType::surrogateValue(dictField.tableName(), dictField.name(), _eventType.parmOriginalValue());
    currentValue = EventType::surrogateValue(dictField.tableName(), dictField.name(), _eventType.parmCurrentValue());
    }
    else
    {
    previousValue = strfmt('%1',_eventType.parmOriginalValue());
    currentValue = strfmt('%1',_eventType.parmCurrentValue());
    }
    }
    else
    {
    dictEnum = new SysDictEnum(dictField.enumId());
    previousValue = dictEnum.value2Label(_eventType.parmOriginalValue());
    currentValue = dictEnum.value2Label(_eventType.parmCurrentValue());
    }

    parameterMap.insert('beforevalue',previousvalue);
    parameterMap.insert('aftervalue',currentValue);

    data = strfmt('%1: %2; %3: %4', "@SYS69521",previousVAlue,"@SYS91541",currentValue);
    }

    drillDownGroup = EventDrillDownPoller::currentDrillDownNavigationMark();

    parameterMap.insert('occurred',datetime2str(DateTimeUtil::applyTimeZoneOffset(_inbox.AlertCreatedDateTime, DateTimeUtil::getUserPreferredTimeZone()), DateFlags::FormatAll));
    parameterMap.insert('for',_inbox.AlertedFor);
    if (_inbox.GlobalRule == NoYes::No)
    parameterMap.insert('company',_inbox.CompanyId);
    else
    parameterMap.insert('company',"@SYS314900");
    parameterMap.insert('data',data);
    parameterMap.insert('subject',_inbox.Subject);
    parameterMap.insert('message',_inbox.Message);
    parameterMap.insert('LinkToBusinessData', drillDownGroup + '?DrillDown_' + int642str(_inbox.InboxId));
    parameterMap.insert('LinkToAlertRule', drillDownGroup + '?ViewAlertRule_' + int642str(_inbox.InboxId));
    parameterMap.insert('LinkToAlert', drillDownGroup + '?ViewAlert_' + int642str(_inbox.InboxId));
    parameterMap.insert('event', event);
    parameterMap.insert('alertid',int642str(_inbox.InboxId));

    return parameterMap;
    }

  • D365  beginner Profile Picture
    634 on at

    Any help would be highly appreciated.

  • Vigneshvaran Profile Picture
    354 on at

    how did you done this?

    Now i need to add one extra field in the email template %for%.

    how can i add one extra field, am not aware of this. Please do the needful.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans