email notifications to service catalog tasks "assigned to" persons

usekjan
Kilo Explorer

Backstory.... I am new to this so I am requesting help

At my company... a New Hire service catalog requests have 1 req, and multiple RITM's. In each RITM there can be and usually has multiple catalog tasks assigned and assigned to multiple users directly in order to fulfill the request.

What I want is to setup is a email notification that when something is added the RITM's "Additional comments" section ALL users assigned to any of the related catalog tasks are emailed telling them that there is additional info added. I am having issues on the "who will receive" tab. I am using the

On the "wend to send" I have inserted and updated checked and in the conditions I have "additional comments" changes

On the "what it will contain" I would like the info that was entered in the "addition comments" to be placed in the Message.  

Any HELP would be very much appreciated!!!

6 REPLIES 6

ok.. .you aren't going to be able to do it from an action.. and you are going to want to loop through all tasks... sooo..



set the condition to additional comments changes



check adavanced   and you should see a tab you can put a script in.. we will need a script to find all tasks and update them... forgive me if there are spelling errors this is psuedo code i am just creating....



var update = current.additional_comments.toString();


var tsk = new GlideRecord('sc_task');


tsk.addQuery('sc_req_item',current.sys_id);


tsk.query();


while(tsk.next()){


    tsk.work_notes = update;


    tsk.update();


}


Ok so a Business Rule.

For clarity with us new travelers on this journey.
You're saying...
--------

Create a new BR.

Give it a name: Name [ Update task work note field ]
Point it to a table: Table [ sc_req_item ]
Click the Advanced checkbox: Advanced [x]
Select the Advanced tab: | Advanced |
Set the Condition field: Condition [ To something, I don't know ]
  | set the condition to additional comments changes

current.task.work_notes?
!current.task.work_notes?
current.comments_and_work_notes?
current.parent.comments_and_work_notes?
current.work_notes?

I'm not entirely sure here...help

Add this to the Script field:

(function executeRule(current, previous /*null when async*/) {


// Grab comments from our request item
var update = current.additional_comments.toString();

// Instantiate a GlideRecord object
var tsk = new GlideRecord('sc_task');

// Build our query to run against sc_req_item table
tsk.addQuery('sc_req_item',current.sys_id);

// Run our query
tsk.query();

// Loop thru our results
while(tsk.next()){

// Assigned task work notes with comments from RITM
tsk.work_notes = update;

// Update our table entry
tsk.update();

}

})(current, previous);

 

Do I change the | When to run | tab?

How about the | Actions | tab?

And then essentially do the reverse for Task to RITM?