- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2018 08:43 AM
Hi gang,
I want to put together a notification that will send to users who are entered into a reference field on child tasks of a parent record.
Here's the scenario:
I have a custom table [x_cur_oc_feedback_oc_feedback] that has a [comments] field; this table is extended from task. Records in this table can have related child tasks. The child tasks have a custom field [business_contact] for assigning the task.
If the [comments] section on the parent record changes, I want a notification to be sent to the users entered in the [business_contact] field on the child tasks associated with the parent record (if there are any).
What's the best way to do this?
Should I write an email script to do a GlideRecord query to get the names in the [business_contact] field on the child tasks? How do I then set that list of names as the recipient of the email?
Or should I create an event that triggers a script action that queries and passes the names for the recipients of the email?
not sure which way to go...thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2018 08:56 AM
Based upon the recent suggestions,here is the script for the Business Rule:
(function executeRule(current, previous /*null when async*/) {
// Query for existing child tasks and gather list of any actionees
var gr = new GlideRecord('x_cur_oc_feedback_tasks');
gr.addQuery('parent',current.sys_id);
gr.query();
var bcArray = [];//array of business contacts from child tasks
while(gr.next()){
if (gr.business_contact !=''){
if (bcArray.toString().indexOf(gr.business_contact) == -1){
bcArray.push(gr.business_contact.toString());
}
}
}
gs.eventQueue('x_cur_oc_feedback.comments.added.notify',current,bcArray,'','');
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2018 09:17 AM
thanks again for your help Christopher!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2018 04:12 PM
now one more question regarding this task...there's a reference field on the parent record to the [sys_user] table, and then there's our [business_contact] field on the child table that is also a reference to [sys_user]. If these 2 values are the same, I need this notification to NOT send.
can I do a script in the notification's Advanced Condition script section to achieve this logic?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2018 04:20 PM
to clarify further, each parent record might have multiple child tasks, if any of the child tasks have the "business_contact" equal to the value of the reference field on the parent record, I need that recipient to not get this notification. I was thinking of using the "Weight", however I'm seeing that the recipient list has be be EXACT for the weight to be considered, and my 2 notifications will not be exact. One notification (the one I always want to send) will always have 1 recipient, and the 2nd (which is related to the business rule and event we just created) might have multiple recipients, one of which might be the same as the one from the 1st notification. This recipient needs to be removed.
Thinking about it more...should this logic be built into the GlideRecord query from the Business Rule that we just finalized?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2018 04:29 PM
I'll start a new thread for this. Thanks again Michael, Christopher and Pradeep!
Remember one of you reply one more time with my final code and I'll mark your answer correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2018 05:10 PM
this ended up being easy...just needed to adjust this line to include the && condition:
if (gr.business_contact !='' && gr.business_contact != current.ocpg_sponsor){ //this is the field on the parent record