Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

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

Posted on by 4
Scenario: 
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.
Categories:
  • 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.
     
    Alternative
     
    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 295 on at
    custom date field from custom table to email outbox(Email Editor) used Send Email functionality
    Hi 

    Please add body message before the send code

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

    Thanks in advance
    Gokul

     
     var
            emailItemL: Record "Email Item" temporary;
            Txt001: Text[100];
        begin
            Txt001 := <<add the details required here>>;
            emailItemL.SetBodyText(Text);
        end;

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans