We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

email script to trigger approval via email with watermark for approve/reject action

Sri56
Tera Contributor

Hi,

 

can someone explain how to trigger an email script to trigger approval via email with watermark for approval action.

1 ACCEPTED SOLUTION

Tanushree Maiti
Tera Patron

Hi @Sri56 

 

Try this sample steps (Update it as per your requirement):

1: Create the Notification Email Script

  • Navigate to System Notification > Email > Notification Email Scripts > click New.
  • Set the Name to links_custom_approval.

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,

    /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,

    /* Optional GlideRecord */ event) {

    var watermark = email.watermark;

    var approveSubject = "Re: Approval for " + current.sysapproval.getDisplayValue() + " - Approve";

    var approveBody = "I approve this request.\n\n" + watermark;

    var approveLink = "mailto:" + gs.getProperty('glide.email.user') +

                      "?subject=" + encodeURIComponent(approveSubject) +

                      "&body=" + encodeURIComponent(approveBody);

 

    var rejectSubject = "Re: Approval for " + current.sysapproval.getDisplayValue() + " - Reject";

    var rejectBody = "I reject this request.\n\n" + watermark;

    var rejectLink = "mailto:" + gs.getProperty('glide.email.user') +

                     "?subject=" + encodeURIComponent(rejectSubject) +

                     "&body=" + encodeURIComponent(rejectBody);

    template.print('<a href="' + approveLink + '" style="background-color: #4CAF50; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px; font-weight: bold; margin-right: 10px;">Click here to Approve</a>');

    template.print('<a href="' + rejectLink + '" style="background-color: #f44336; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px; font-weight: bold;">Click here to Reject</a>');

 

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

 

2: Embed the Script into your Email Notification

  • Open the ServiceNow email notification targeted at the Approval [sysapproval_approver] table.
  • Navigate down to the What it will contain section/tab.
  • In the Message HTML ,insert the following tag where you want your actionable buttons to appear:
    ${mail_script:links_custom_approval}
  • Check the Omit watermark checkbox if you want to prevent the global duplicate watermark string from appending to the very bottom of the template layout.

 

3: Verify Inbound Email Processing

  • The native platform behavior expects inbound processing rules to scan the user's incoming subject line and body text for keywords like approve or reject paired alongside the valid matching record watermark.
  • Ensure your Inbound Email Actions configured for Approvals remain active to successfully parse the response and transition your workflow states.

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

View solution in original post

3 REPLIES 3

vaishali231
Kilo Sage

Hey @Sri56 

ServiceNow supports email-based approvals out of the box. The process relies on Notifications, Email Scripts, Email Watermarks, and Inbound Email Actions working together. Below is a step-by-step explanation of the complete flow.

 

How the Approval Process Works

Step 1: An Approval Record is Created

When an approval is generated (through Workflow, Flow Designer, or Approval Engine), ServiceNow creates a record in the sysapproval_approver table.

Example:

Requested Item submitted

Manager approval generated

Record inserted into sysapproval_approver

Approval State = Requested

This approval record becomes the source for the approval notification.

 

Step 2: Approval Notification is Triggered

Create (or use the OOB) Notification on the sysapproval_approver table.

Typical configuration:

Table: sysapproval_approver

When to Send: Record inserted (or state changes to Requested)

Recipient: Approver

Condition: State = Requested

The notification sends the approval email to the approver.

 

Step 3: Include an Email Script

Within the notification body, include the appropriate mail script.

Example:

${mail_script:approval_request}

 

or another OOB approval mail script depending on your ServiceNow release.

The mail script typically generates:

  1. Approval details
  2. Record information
  3. Approve/Reject instructions
  4. Links (if configured)
  5. Email formatting

You can also create your own Email Script if you need custom formatting.

 

Step 4: ServiceNow Automatically Adds a Watermark

This is one of the most important parts.

Whenever ServiceNow sends an email through the Notification engine, it automatically appends an email watermark.

Example:

Ref:MSG0d2c2d8cdb123010d9b8e9b4ca9619f6

 

or

Ref:MSGxxxxxxxxxxxxxxxxxxxxxxxx

 

The watermark uniquely identifies the record that generated the email.

You do not need to manually generate or append the watermark.

As long as the email is sent through the standard Notification framework, ServiceNow handles this automatically.

 

Step 5: User Replies to the Email

The approver simply replies to the email.

Example reply:

Approve

 

or

Reject

 

The watermark remains in the email thread.

 

Step 6: Incoming Email is Received

When the reply reaches ServiceNow:

  1. Email Reader retrieves the email.
  2. ServiceNow reads the watermark.
  3. The watermark identifies the original approval record.
  4. The email body is analyzed.

 

Step 7: Inbound Email Action Executes

ServiceNow includes Out-of-the-Box Inbound Email Actions for approvals.

The inbound action performs tasks such as:

Reading the watermark

Finding the corresponding sysapproval_approver record

Looking for approval keywords

Examples:

Approve

Approved

Yes

 

or

Reject

Rejected

No

 

If a valid keyword is found:

Approval State → Approved

or

Approval State → Rejected

Step 8: Workflow or Flow Continues

Once the approval state changes:

  1. Flow Designer resumes
  2. Workflow continues
  3. Next approval is generated (if applicable)
  4. Catalog Item proceeds
  5. Change Request moves to the next stage

Complete End-to-End Flow

Workflow / Flow Designer

            │

            ▼

Approval Record Created

(sysapproval_approver)

            │

            ▼

Notification Triggered

            │

            ▼

Email Script Generates Email

            │

            ▼

ServiceNow Appends Watermark

            │

            ▼

Approver Receives Email

            │

            ▼

Replies with "Approve" or "Reject"

            │

            ▼

Inbound Email Received

            │

            ▼

Watermark Identifies Approval Record

            │

            ▼

Inbound Email Action Executes

            │

            ▼

Approval State Updated

            │

            ▼

Workflow / Flow Designer Continues

Best Practice

Rather than creating custom watermark logic, use the Out-of-the-Box approval notifications and inbound email actions provided by ServiceNow. They automatically handle watermark generation, record correlation, and approval processing, making the solution easier to maintain and fully supported across platform upgrades.

If you have a custom approval process, you can still leverage the same mechanism by sending notifications from the sysapproval_approver table (or your custom approval table) and configuring an appropriate Inbound Email Action to process the reply using the watermark.

 

************************************************************************************************************************************

If this response helps, please mark it as Accept as Solution and Helpful.

Doing so helps others in the community and encourages me to keep contributing.

Regards

Vaishali Singh

Servicenow Developer
Linkedin - https://www.linkedin.com/in/vaishali-singh-2273361bb




Ankur Bawiskar
Tera Patron

@Sri56 

if you are talking about approval on sysapproval_approver then the email notification is already available out of the box which has links to approve/reject and every outbound email has watermark included unless it's explicitly disabled at notification level

Why you want new one?

this is the OOTB email notification

AnkurBawiskar_0-1784541961471.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Tanushree Maiti
Tera Patron

Hi @Sri56 

 

Try this sample steps (Update it as per your requirement):

1: Create the Notification Email Script

  • Navigate to System Notification > Email > Notification Email Scripts > click New.
  • Set the Name to links_custom_approval.

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,

    /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,

    /* Optional GlideRecord */ event) {

    var watermark = email.watermark;

    var approveSubject = "Re: Approval for " + current.sysapproval.getDisplayValue() + " - Approve";

    var approveBody = "I approve this request.\n\n" + watermark;

    var approveLink = "mailto:" + gs.getProperty('glide.email.user') +

                      "?subject=" + encodeURIComponent(approveSubject) +

                      "&body=" + encodeURIComponent(approveBody);

 

    var rejectSubject = "Re: Approval for " + current.sysapproval.getDisplayValue() + " - Reject";

    var rejectBody = "I reject this request.\n\n" + watermark;

    var rejectLink = "mailto:" + gs.getProperty('glide.email.user') +

                     "?subject=" + encodeURIComponent(rejectSubject) +

                     "&body=" + encodeURIComponent(rejectBody);

    template.print('<a href="' + approveLink + '" style="background-color: #4CAF50; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px; font-weight: bold; margin-right: 10px;">Click here to Approve</a>');

    template.print('<a href="' + rejectLink + '" style="background-color: #f44336; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px; font-weight: bold;">Click here to Reject</a>');

 

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

 

2: Embed the Script into your Email Notification

  • Open the ServiceNow email notification targeted at the Approval [sysapproval_approver] table.
  • Navigate down to the What it will contain section/tab.
  • In the Message HTML ,insert the following tag where you want your actionable buttons to appear:
    ${mail_script:links_custom_approval}
  • Check the Omit watermark checkbox if you want to prevent the global duplicate watermark string from appending to the very bottom of the template layout.

 

3: Verify Inbound Email Processing

  • The native platform behavior expects inbound processing rules to scan the user's incoming subject line and body text for keywords like approve or reject paired alongside the valid matching record watermark.
  • Ensure your Inbound Email Actions configured for Approvals remain active to successfully parse the response and transition your workflow states.

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti