Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Custom fields on email alert templates AX 2012

Posted on by 572

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 

  • vigneshvaran Profile Picture
    vigneshvaran 326 on at
    RE: Custom fields on email alert templates AX 2012

    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.

  • D365  beginner Profile Picture
    D365 beginner 572 on at
    RE: Custom fields on email alert templates AX 2012

    Any help would be highly appreciated.

  • D365  beginner Profile Picture
    D365 beginner 572 on at
    RE: Custom fields on email alert templates AX 2012

    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;
    }

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Custom fields on email alert templates AX 2012

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

  • D365  beginner Profile Picture
    D365 beginner 572 on at
    RE: Custom fields on email alert templates AX 2012

    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.

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Custom fields on email alert templates AX 2012

    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.

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans