- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2025 11:32 PM
Hi Team,
My use case is to open an outlook email upon clicking a button on a workspace form. I thought to use a declarative action implemented as a server script which includes below line:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 12:20 AM
you need to use client side UI action and write code in workspace client script for this.
Something like this
function onClick(g_form) {
var email = 'recipient@example.com';
var subject = 'Subject of the email';
var body = 'This is the email body.';
// Construct the mailto link
var mailtoLink = 'mailto:' + email + '?subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(body);
// Open the email client
open(mailtoLink);
}
Output: when I clicked it opened this
Then I selected Outlook app and it opened the email form
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 12:22 AM
Why would you like to use a Declarative action for this? It works with a simple client side UI action (or client side declarative action)
Just use the following example script (I tried with window.location however it always returned undefined in the console which shouldn't have happened):
function executeAction() {
var subject = "Test Subject";
var body = "Hello from ServiceNow UI Action!";
var mailto_link = "mailto:someone@example.com?subject="
+ encodeURIComponent(subject)
+ "&body="
+ encodeURIComponent(body);
top.location.href = mailto_link;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 12:24 AM
Thank you all! Much appreciated.