Add a Related List records to email notification

Sofija
Giga Expert

Hi All,

I created an email notification to be issued from Problem table, however I am struggling to pull all problem tasks related to that problem. In other words, I would like to send email notification informing about the problem record with all of it's problem task record. Problem task records must include number, short description, assignment group and a due date.

This seems like something that a lot of user would probably want to issue and kind of a common sense, but it does not seem to be built in to ServiceNow. I found some examples regarding email scripts or database views, but none are tailoring to this simple quest.

Does anyone have any suggestions how I could achieve pulling all related problem tasks to a problem record email notification or possibly done something similar previously?

Any thoughts and suggestions are much appreciated!

Kind Regards,

Kamile

1 ACCEPTED SOLUTION

srinivasthelu
Tera Guru

Hi Kamile,



Email Script with GlideRecord on Problem task should do the job.



Basically,



Create a Notification script and add below code to pull the information of related   problem tasks with something like below.



var gr=new GlideRecord('problem_task')


gr.addQuery('problem', current.sys_id);


gr.query();


while(gr.next()){


template.print("number:" gr.getValue('number'));


template.print("short_description", gr.getvalue('short_description'));


}




Hope this helps


Srini



Mark this response as helpful/correct if it does so


View solution in original post

6 REPLIES 6

Well nevermind, beat at it long enough and eventually it will work, right?  



Here's my script for pulling active Issues from a notification triggered by a Status Report (PPM) in case anyone needs the reference:



var gr=new GlideRecord('issue');


gr.addQuery('parent', current.project);


gr.addQuery('active', true);


gr.orderBy('number');


gr.query();


while(gr.next()){


template.print(gr.number + " " + gr.short_description + "\n");


}


thomasm1
Mega Contributor

I would really like to see the script you made Kamila. Is it possible?

 

Regards Thomas