- 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:13 AM
Use below code in your notification
<mail_script>
email.setFrom(current.parent.project_manager.email);
</mail_script>
Click below link for more details how to set from address
Scripting for Email Notifications - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2015 06:14 AM
Write a business rule on pm_project_task table
After
insert/update
in the script part use
var ev1 = current.parent.project_manager
gs.eventQueue('event', current, ev1, ev1);
and in the mail notification you can check the boxes to sent email to event parameter 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2015 06:35 AM
Anurag Tripathi -I am not exactly sure I understood. You told me to create a business rule on pm_project_task and then setup a notification on that table, where the recipient would be the event creator? If so, I tried but for some reason it's not sending an email to the project manager.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2015 06:39 AM
can you use gs.infoMessage or gs.log to check that are you getting the sys_id of project manager in the br??
and in the Email Notification, along with the send to event createor, there are 2 more check boxes...parameter 1 and 2...check those also.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2015 06:32 AM
If you would like to send immiade parent project instead of project task use below code
For ex: PR00100-->PRJTASK00100-->PRJTASK00101-->PR00101-->PRJTASK00102-->PRJTASK00103
Fro mthe above example "getProject" can return "PR00101" so you can this project manager mail id and send to him
var project_id = getProject(current.task);
g_scratchpad.u_project_number = project_id;
function getProject(planned_task_number)
{
var return_sys_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;
if(gr.parent.sys_class_name == 'pm_project')
{
return_sys_id = pl_task_number;
return return_sys_id;
}
else
{
return_sys_id = getProject(pl_task_number);
}
}
if(return_sys_id !='' || return_sys_id != 'undefined')
{
return return_sys_id;
}
else
{
return return_sys_id;
}
}