- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2015 05:46 AM
Hi SNC,
I have a case with Project Management - I want to set up a notification which will be sent to the Project Manager of a project, when a project task from that project is updated.
The issue is - when I try to setup a notification for the pm_project_task table, I cannot refer to the Project Manager field, as this field is from the pm_project table.
Another thing I want to do is - is there a way to add a field to the project task form, which shows the project they belong to. I think this would be very useful.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2015 07:11 AM
1) Create new event called "project.task.update.to.pm'
2)Create new email notification
1)When to send : Send when-->Event is fired-->Event name you can select is :project.task.update.to.pm
2)Who will receive :Send to event creator-->Event parm 1 contains recipient : true
3)Create before update business rule
var project_manager = getProject(current.sys_id);
gs.eventQueue("project.task.update.to.pm", current, project_manager, '');
function getProject(planned_task_number)
{
var return_sys_id = '';
var mgr_mail_id ='';
var pl_task_number = planned_task_number;
var gr = new GlideRecord('pm_project_task');
gr.addQuery('sys_id', pl_task_number);
gr.query();
if(gr.next())
{
pl_task_number = gr.parent;
mgr_mail_id = gr.parent.project_manager;
if(gr.parent.sys_class_name == 'pm_project')
{
return_sys_id = pl_task_number;
return mgr_mail_id;
}
else
{
mgr_mail_id = getProject(pl_task_number);
}
}
if(JSUtil.notNil(mgr_mail_id))
{
return mgr_mail_id;
}
else
{
return mgr_mail_id;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2015 06:42 AM
Harish Murikinati - hm, interesting. Where should that code go?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2015 07:11 AM
1) Create new event called "project.task.update.to.pm'
2)Create new email notification
1)When to send : Send when-->Event is fired-->Event name you can select is :project.task.update.to.pm
2)Who will receive :Send to event creator-->Event parm 1 contains recipient : true
3)Create before update business rule
var project_manager = getProject(current.sys_id);
gs.eventQueue("project.task.update.to.pm", current, project_manager, '');
function getProject(planned_task_number)
{
var return_sys_id = '';
var mgr_mail_id ='';
var pl_task_number = planned_task_number;
var gr = new GlideRecord('pm_project_task');
gr.addQuery('sys_id', pl_task_number);
gr.query();
if(gr.next())
{
pl_task_number = gr.parent;
mgr_mail_id = gr.parent.project_manager;
if(gr.parent.sys_class_name == 'pm_project')
{
return_sys_id = pl_task_number;
return mgr_mail_id;
}
else
{
mgr_mail_id = getProject(pl_task_number);
}
}
if(JSUtil.notNil(mgr_mail_id))
{
return mgr_mail_id;
}
else
{
return mgr_mail_id;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2015 12:32 AM
Worked perfectly, I was missing some parts of the logic of the function where you get the Project Manager ID. Thanks everyone!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2015 11:22 AM
I realize that this thread is already marked as answered, but I wanted to provide an alternative solution to add the Project Manager into the CC field on a pm_project_task notifications. It doesn't directly achieve adding the PM to the To: field on your notifications, but in some circumstances, the CC line is appropriate and serves to include the PM on the project task notification.
1) create a mail script called pm_project_task_cc_project_manager or whatever you like.
2) script contents
email.addAddress("cc", current.top_task.project_manager.email, current.top_task.project_manager.getDisplayValue());
(addAddress(String type, String address, String displayname): type can be cc or bcc - Scripting for Email Notifications - ServiceNow Wiki)
3) Add mail script call to your notification in the html editor
${mail_script:pm_project_task_cc_project_manager}
This method takes advantage of the top_task reference field on the pm_project_task record where you can dot walk to the project_manager.email value. The iterations for getting to the parent task with the project manager are performed on the dictionary item for top_task, and you do not have to script the iterations to get to the parent.project_manager.email value. It works because the project_manager field is on the parent/top_task which is of the pm_project type.
-Daniel