- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 06:36 AM
I am looking for a way to change the existing mail_script API ${mail_script:ng_activity_mention_body} to display the @Mentions from work notes, instead of just the link to view messages in an incident.
-Thx!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2017 10:55 AM
See in bold below how we edited the ng_activity_mention_body to accomplish this. We also edited the subject of the emails above.
var recordGR = new GlideRecord(current.table);
if(recordGR.get(current.document)) {
email.setSubject("You have been mentioned in " + recordGR.number +" | " + recordGR.getDisplayValue());
template.print("<p style='color: #424E5B;margin: 0 0 12px;line-height: 26px;margin-bottom: 12px'>You have been mentioned by " + current.user_from.name + " in <a href='/" + recordGR.getRecordClassName() + ".do?sys_id=" + recordGR.getUniqueValue() + "'>" + recordGR.getDisplayValue() + "</a></p>");
if (current.field_name == "comments") {
template.print(recordGR.comments.getJournalEntry(1) + "<br />");
}
else if (current.field_name == "work_notes") {
template.print(recordGR.work_notes.getJournalEntry(1) + "<br />");
}
}
Code thanks to Mike Kaufman!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 06:51 AM
Hello Jason,
Please excuse me, but I do not get your request correctly, I believe.
What exactly do you mean under "@Mentions"?
Do you want whenever someone leaves any Work Notes in an incident, for example - the email notification which will be forwarded to the respective user to contain the name of the user who left the Work Notes + what the exact Work Notes (text)?
Could you please clarify your request in details? Thank you!
P.S: if what I described above is the goal of yours - then it is not necessary to use an email script.
Instead of this you may modify the used notification itself, in its item called "What it will contain". Depending of the configuration of yours, the final result my look like the below screenshot, taken from one email notification of mine:
Best Regards,
Georgi Mavrodiev
IT Consultant
Do IT Wise
You may visit us in our Web Site: www.doitwise.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 06:59 AM
Hi Georgi,
Thank you for your reply!
What I am referring to is when someone mentions you in Work Notes (i.e. "@Georgi"); the notification will display the content of that message in the body, itself. Currently, the script above only displays, "You have been mentioned by '@User.'" which requires a hyperlink to view the message.
TY!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 08:15 AM
Hello Jason,
I got you now. Thank you for the clarification!
Well, in this situation, I would create two things: 1. new (custom) Notification Email Script + 2. new (custom) Email Notification, in order not to interrupt (mess) the default ones.
I would set the Notification against the table I desire and will add the script in it (as "Activity Stream @Mention Email" Notification uses "ng_activity_mention_body" Notification Email Script).
The body of the Email script will have to be written by you. I am pretty sure the one of "ng_activity_mention_body" can be used and just modified.
If not today's evening, then tomorrow morning I will perform some test in my DEV and will get back to you with the exact script body, to say so.
Best Regards,
Georgi Mavrodiev
IT Consultant
Do IT Wise
You may visit us in our Web Site: www.doitwise.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2017 08:14 AM
Hello Jason,
Please apologize for the delay!
To be honest, I spent the last 24 hours in trying to achieve your goal.
I copied both the "Activity Stream @Mention Email" and "ng_activity_mention_body" (made copies of them by adding _2 at the end) and also de - activated the default Activity Stream @Mention Email Notification.
Then, I started playing around with the script. Yet, I was not able to make the comment / work note to be visible in the email notification.
I believe everything is because of the fields of the live_notification table.
Thus, I tried another approach by changing the table to sys_journal_field. Yet, there is no User field there, which to be added into the recipient_fields field of the 'Who will receive' item.
I will need to think more about how the goal here can be achieve.
I am sure there is a way. It will just consume some time to be discovered
Best Regards,
Georgi Mavrodiev
IT Consultant
Do IT Wise
You may visit us in our Web Site: www.doitwise.com