Display contents of a HTML field from change form in email body

Sourabh1
Tera Contributor

Hi All,

 

I would like to request for a help. 

I would like to display contents of a HTML field( a custom field created ) from change form in email body. The ${field_name} does not work. Is there a way to achieve this.

 

Thanks and Regards

Sourabh

3 REPLIES 3

Deepak Shaerma
Kilo Sage

Hi @Sourabh1 
Create a Mail Script:

 Navigate to System Notification > Email > Notification Email Scripts.
2. Click “New” to create a new Email Script.
3. Give Name 

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

          if (current && current.u_custom_html_field) {
        return current.u_custom_html_field.getHTMLValue(); // or just .toString() if getHTMLValue() is not appropriate
    }
    return ''; 

})(current, template, email, email_action, event);

 

Step 2: Use the Mail Script in Your Email Notification Template

1. Navigate toSystem Notification > Email > Notifications.
2. Open the notification where you want to include the HTML content.
3. In theMessage HTMLfield (ensure the email format is set to HTML), use the${mail_script:script_name}notation where you want the HTML content to appear.
example:

<p>Here is the content from our custom HTML field:</p>
${mail_script:DisplayHTMLField}
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma 


Hi Deepak,

 

I was making a mistake some where and ${field_name} works in body of email as well for fetching HTML field values. I was populating the custom HTML field via a script and some other script was over writing it and making it null and that is why nothing was showing. I have corrected that issue and now ${field_name} works.

 

Thanks for your help.

 

Sourabh

Looks good. Cheers .

Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..

- Keep Learning ‌‌

Thanks & Regards 

Deepak Sharma