Skip to main content



No record found.

Business Central forum
Suggested answer

custom date field from custom table to email outbox(Email Editor) used Send Email functionality

Posted on by 4
We have a custom page named "Holiday Master" On this page, holidays are listed for a company using a date field. We want to send an announcement of holidays to all employees via email. To achieve this, we have added an action button labeled "Send Holiday Announcement Email" On this action button, we have added code :
Helping from system code "Send Email" functionality.
 The Result is 
Requirement :
  1. When we click the action button "Send Holiday Announcement Email," the date field should flow from the Holiday Master table to the email outbox table (Email Editor Page), as we need to mention that date in the email.
  2. The user can change the email body and use different templates. When they click on "Send Mail" (Note: this will be a custom button on the email editor), it will send the email to different employees via a loop.
  • Pons J. Llaneras Profile Picture
    Pons J. Llaneras 52 on at
    custom date field from custom table to email outbox(Email Editor) used Send Email functionality
    I can't tell you how to solve this problem in particular, but I'll give you the way you must follow to solve this kind of problems.
    Follow these steps:
    1. If you want to add a value, start by adding a field in the table you interact with (in your case, add a date field in "Email Item").
    2. Look at which table and page you want the information to be displayed, if the table is the same as point 1, you need to add the field to the page and that's it, if not, continue reading.
    3. In a sandbox, debug your action to see what the system is doing to get to the table and page that is displayed to the user, look for events where you can subscribe in order to transfer the value until the value reaches the table and page displayed to the user. You will have to add the field to all intermediate tables until the field reaches the last one. Add the field to the page you want to display the information.
    Note that this is not always possible, if some table is internal or onprem (in the case you need to make it work for cloud), you will not be able to add any field to the table. Another problem are the events, it is possible that you may not find any event with the vars needed to do the transfer of the value.
    If you don't need the value to be persistent in the table, you can use a single-instance codeunit: SingleInstance Property - Business Central | Microsoft Learn.
    My recomendation is to never use this kind of codeunits, but sometimes there is no other way to pass values between procesess when you don't control the code that is executed.
    Follow these steps:
    1. In you action, set the value with a function in your single-instance codeunit
    2. In the trigger OnOpen of the page where you want to display the value, get the value from the single-instance codeunit using another function
    3. In the trigger Onclose of the page where you display the value, clear the value. This is important because the single-instance codeunit will keep the values in the user session, and if the user opens the same page for other things, the value will be displayed.
  • Suggested answer
    Shahid Ali Profile Picture
    Shahid Ali 4 on at
    custom date field from custom table to email outbox(Email Editor) used Send Email functionality
    Thank you for your valuable input. As per your suggestion, we can add the date in the body message before sending. However, if the user uses different templates in the Email Editor, the body message may not include this date.
    That's why I think we need to flow the custom date from the holiday master to the email outbox. I would appreciate it if you could consider this again and provide your valuable input. Thanks again.
  • Tech_BC_Gokul Profile Picture
    Tech_BC_Gokul 263 on at
    custom date field from custom table to email outbox(Email Editor) used Send Email functionality

    Please add body message before the send code

    In your boday message you can draft the message box with dates. 

    Thanks in advance

            emailItemL: Record "Email Item" temporary;
            Txt001: Text[100];
            Txt001 := <<add the details required here>>;

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,989 Super User

Martin Dráb Profile Picture

Martin Dráb 225,588 Super User

nmaenpaa Profile Picture

nmaenpaa 101,148


Featured topics

Product updates

Dynamics 365 release plans