Email Notification is going out with 'Code' text
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2023 01:47 AM
Hi,
Im having a problem that my notification is going out with the word 'Code' at the top and at the bottom. it happens only when I add comments or work_notes in the service operation workspace (I think its because the comments and workontes in the workspace are HTML).
This is my script:
function runMailScript( /* GlideRecord */ current, / TemplatePrinter */ template, /Optional Emailoutbound */
email, / Optional GlideRecord / email_action,
- /* Optional GlideRecord */
event) {
var commentorName event.parm2;
var userGr= new GlideRecord('sys_user 8 userGr.addQuery('sys_id, commentorName);
');
userGr.query();
if (userGr.next()) {
commentorName= userGr.name;
var user_name = userGr.user_name.toString();
}
var gr new GlideRecord('sys_journal_field");
gr.addEncodedQuery("sys_created_by=+ user_name); gr.orderByDesc("sys_created on) ;
gr.query();
if (gr.next()) { var comment gr.value.toString();
template.print(commentorName+":"+comment + "\"");
(current, template, email, email action, event);
The email output (ttt is the comment message):
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2023 02:48 AM
Hi
due to security reasons HTML in the journal fields like work notes or additional comments are enclosed in
[code] ... [/code] blocks.
These starting and ending "tags" have to be removed first before inserting the content into the email.
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2023 03:01 AM
@Maik Skoddow hi, how can I remove them using the code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2023 04:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2023 03:31 AM
try this:
function runMailScript(current, template, email, email_action, event) {
var commentorName = event.parm2;
var userGr = new GlideRecord('sys_user');
userGr.addQuery('sys_id', commentorName);
userGr.query();
if (userGr.next()) {
commentorName = userGr.name;
var user_name = userGr.user_name.toString();
}
var gr = new GlideRecord('sys_journal_field');
gr.addEncodedQuery('sys_created_by=' + user_name);
gr.orderByDesc('sys_created_on');
gr.query();
if (gr.next()) {
var comment = gr.value.toString();
template.print(commentorName + ': ' + comment + '"');
// Add your email processing logic here if needed.
}
}
