@mentions notification to include ticket details

michaelbcp
Kilo Contributor

I’m working on changing the @mentions notification to include ticket details like the short description, requested for, Requested by, and assignment details.

I’m not very good with javascripting.  I’m looking for help to create an email script that can understand which table to grab these details from and print them out into the notification.

I’m guessing the script will need to:

1. determine which table the information resides on (@mentions can happen on Incident, REQ, RITM, SCTASK, Problem, and change tickets).

2. then state what info will be needed (ie. Requested For Name, Short Description, etc)

3. validate that the info is present.

4. pull the info

5.and then print it out into the notification.

Am I on the right track?  Can anyone provide any documentation links that would help me create this (feel free to write a script if you’d like 🙂 )?

 

Thanks!

5 REPLIES 5

Maverick E
Tera Guru

Hello michaelbcp,

To accomplish this, you will need to create an email script with the following details:

Since you are working with a notification that can be applied on multiple tables like (incident, problem, change) we will need to create conditions for the script. In the below example, I used the incident table. But with this code, you can create as many If statements as you want depending on which tables you want to cover.

if (current.table == 'incident'){
var tr = new GlideRecord('incident');
tr.addQuery('number', current.title);
tr.query();

if (tr.next()){
    template.print("Short Description: "+tr.short_description);
    template.print("Description: "+tr.description);
 }
}

 

We are checking which table the notification is on, then we will query the record and print the extra information in the email by using template.print();

I recommend staying away from using "gr" as a variable as this has caused issues for me in the past. 

If you want to add another condition: e.g. the problem table, then you can copy the same code and just change the table and which information to print.