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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Implementation of Dynamic Field Placeholders in Alert Rule Subject and Message (X++ Customization)

(2) ShareShare
ReportReport
Posted on by 213

Hi everyone,

I have successfully implemented a requirement to allow users to insert dynamic field placeholders (e.g., %CustTable.AccountNum%) into both the Subject and Message body of an Alert Rule.

I’m sharing the logic I used to see if there are any recommended improvements or if this helps anyone else facing the same requirement.

The Scenario

Standard D365 F&O alerts allow static text in the subject and message. However, users often want the email to contain specific record data (like Customer Name, Document ID, or Amount) without manually typing technical field names.

  • Form Extension (EventCreateRule): - Added two unbound String Controls (Sunb_Placeholder and Sunb_PlaceholderMsg) with LookupButton = Always.

    • Used a FormControlEventHandler to intercept the Lookup event.

    • Within the lookup, I use SysDictTable and SysDictField to iterate through the metadata of the Alert's context table (EventRule.PrimTableId) and populate a temporary buffer with the format %TableName.FieldName%.

  • UI Integration (OnModified):

    • When a value is selected from the lookup, the Modified event triggers.

    • The code snatches the selected placeholder and appends it directly to the EventRule.Subject or EventRule.Message table buffer and refreshes the datasource.

    • The picker control is then reset to a label "Insert Placeholder" to act as a reusable button.

  • Email Processing (EventInbox Extension):

    • Created an extension of the EventInbox.insert() method.

    • After the alert is created, the code identifies the source record using this.AlertedFor (RecId) and this.TableId.

    • A static string-parsing method scans for %...% patterns and uses reflection to replace them with the actual values from the source record buffer before the email is sent.

  • Key Challenges Overcome 

  • Handling the ManagedEventArgs error by avoiding cancelDefault() and relying on the system's redirection.

  • Updating the Rich Text/HTML Message field directly via the buffer to ensure the UI updates correctly.

  • Ensuring the code is generic enough to work for any table context (Customers, Sales Orders, Vendors, etc.).

 

Has anyone implemented a similar placeholder engine? I'm curious if there are better ways to handle the string replacement during high-volume alert processing.

 

Why this works well for a post:

  • Clear Context: You explain the "Why" (The Scenario).

  • Structured Solution: You break it down into Form, UI, and Table levels.

  • Community Engagement: You end with a question, which encourages experts to reply and boost your post's visibility.

 

   
    
 

Categories:
I have the same question (0)
  • KK-22041012-0 Profile Picture
    3 on at
    great job
  • André Arnaud de Calavon Profile Picture
    304,293 Super User 2026 Season 1 on at
    Hi Priya,

    Thanks for sharing your experience. In case your post is intended as blog post, you can request for a blog space on this forum: https://community.dynamics.com/help/?partialurl=request-new-blog

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 688

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 524 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 301

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans