Display Message in Compose Email Window
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2024 05:21 AM
Hello All,
I have been trying to display message on compose email frame whenever user clicks on 'Send' button...
I am using UI Script but I am not sure whether I am using right approach or not...
Could anyone please correct me here?
Thank you in advance!
UI Script:DisplayMsgInMailClient
var global = global || {};
global.DisplayMsgInMailClient = (function() {
"use strict";
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
// Function to display message in the email client
function displayMessageInEmailClient() {
try {
var URL = document.URL;
if (URL.indexOf("/email_client.do?sysparm_table=incident") != -1) {
var tagPosition = URL.indexOf("sysparm_sys_id=");
if (tagPosition != -1) {
var taskSysId = URL.substr(tagPosition + 15, 32);
var task = new GlideRecord("incident");
if (task.get(taskSysId)) { // Use get() instead of hasNext()
// Display a sticky info message using GlideUI
GlideUI.get().addInfoMessage("The Email has been sent");
}
}
}
} catch (e) {
console.log(e); // Log any errors to the console
}
}
// Call the display function when the page loads
addLoadEvent(displayMessageInEmailClient);
// Public API (currently not used in the example, but can be extended as needed)
return {
type: "DisplayMsgInMailClient"
};
})();
0 REPLIES 0