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

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


Hi Srinivas,



Unfortunately, this doesn't work. I had a very similar script but neither yours nor mine worked..


Actually I got it working with my own script somehow just now! Thank you for the help


kamile - can you post your script?   I'm trying to do something similar and haven't been successful.