- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2018 08:34 AM
HI Developers.
I have the following script on a business rule:
(function executeRule(current, previous /*null when async*/) {
//Get the Email record created against this Log
var grEmail = new GlideRecord("sys_email");
if(grEmail.get("sys_id", current.email)) {
//Check for a style associated with the Notification used
var grES = new GlideRecord("u_email_style");
var htmlStyle = "";
var strCSS = "";
var grSEA = new GlideRecord("sysevent_email_action");{
if(grSEA.get("sys_id", current.notification))
// if (grSEA.u_style == '') {
// //no style specifed, exit logic
// return;
// }
if(grES.get("sys_id", grSEA.u_style)) {
htmlStyle = grES.u_style_template;
strCSS = grES.u_css;
}
}
var strBody = grEmail.body;
//gs.log("DEBUG 1: Apply Email Style, strBody = " + strBody);
//gs.log("DEBUG 2: Apply Email Style, htmlStyle = " + htmlStyle);
strBody = strBody.replace("<html>", "");
strBody = strBody.replace("</html>", "");
strBody = strBody.replace("<body>", "");
strBody = strBody.replace("</body>", "");
htmlStyle = htmlStyle.replace("body_text", strBody);
//gs.log("DEBUG 3: Apply Email Style, htmlStyle = " + htmlStyle);
var strEmail = strCSS + "<html><head></head><body>" + htmlStyle + "</body></html>";
grEmail.body = strEmail;
grEmail.headers = grEmail.headers + "\n" + strCSS;
grEmail.autoSysFields(false);
grEmail.setWorkflow(false);
grEmail.update();
}
})(current, previous);
I only want this script to run when the sysevent_email_action.u_type is populated. I have the following condition on the script current.sysevent_email_action.u_style!="" but this is not working. What is wrong with the condition?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2018 09:04 AM
Your code is checking for sysevent_email_action.u_style but you said "I only want this script to run when the sysevent_email_action.u_type is populated." Is there a relation between u_type and u_style? What am I missing here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2018 08:42 AM
What table is your business rule running against?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2018 08:45 AM
sys_email_log is the table the business rule is running on
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2018 09:04 AM
Your code is checking for sysevent_email_action.u_style but you said "I only want this script to run when the sysevent_email_action.u_type is populated." Is there a relation between u_type and u_style? What am I missing here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2018 10:11 AM
rzj what is u_type and u_style in your comment?