sc_task Additional Comments

nyrguy45
Kilo Contributor

Hello All,

I am having issues with "Additional Comments" not being emailed to the Requestor of the task from SC_task

I am new to ServiceNow so not sure as to where to begin looking.

Any help would be highly appreciated.

 

Best,

 

1 ACCEPTED SOLUTION

JR Guieb
Tera Expert

Here is what I did for my company because we had the same requirement.

 

First what I had to do is to create an email notification that will send to the requester whenever Additional Comments are entered into the RITM.

 

Next I created a business rule that will copy the Additional Comments from the catalog task and place them into the RITM. Here is what I did for the business rule:

  • Table = Catalog Task [sc_task]
  • Check Advanced
  • When to run
    • When = Before
    • Update = checked

find_real_file.png

  • Advanced
    • Condition
      • current.comments.changes()
    • var gr = new GlideRecord('sc_req_item');
      gr.get(current.request_item);
      gr.comments = current.comments;
      //gr.work_notes = current.work_notes;
      gr.update();

find_real_file.png

Now when an additional comment is added at the catalog task it will get copied into the RITM, and because there is an email notification setup to send to the requester when an additional comment is added to the RITM the email to the requester will send.  

View solution in original post

17 REPLIES 17

Brian Lancaster
Tera Sage

Send the end user does not have access to the task notification do not go out on it.  Notification go out on the RITM so your best option would be to make sure that comments updated on the task are copied to the RITM.  This can be done by dong a before update business rule.

You will need to click on the advanced checkbox.  On when to run choose before and check the update box.  On the advanced tab add the condition of current.comments.changes().  Then add the below script

 

(function executeRule(current, previous /*null when async*/) {
	// Add your code here
	var user = new GlideRecord ('sys_user');
	user.addQuery('user_name', current.sys_updated_by);
	user.query();
	if (user.next()){
		if (user.sys_id != current.request.requested_for){
			var gr = new GlideRecord('sc_req_item');
			gr.get(current.request_item);
			gr.comments = current.comments;
			gr.update();
		}
	}
	
})(current, previous);

You may want to do something similar are for a RITM business rule.  It will have the same condition but the following code so that way then a user responds it gets copied to the task. It would also be a before update

(function executeRule(current, previous /*null when async*/) {
	
	var sctask = new GlideRecord('sc_task');
	sctask.addQuery('request_item.number', current.number);
	sctask.query();
	while (sctask.next()) {
		var user = new GlideRecord ('sys_user');
		user.addQuery('user_name', current.sys_updated_by);
		user.query();
		if (user.next()){
			if (user.sys_id == current.request.requested_for){
				sctask.comments = current.comments;
				gs.eventQueue('ctl.comments_sctask.notification', sctask);
				sctask.update();
			}
		}
	}
})(current, previous);

nyrguy45
Kilo Contributor

Hello and thank you for your response and assistance I greatly appreciate it.

 

I created the business rule as you suggested for the SC_TASK as shown below

find_real_file.png

find_real_file.png

 

unfortunately, it is still not working.  When i add additional notes via the SCTASK those notes are not relayed to the RITM.  Possibly you can check that i have done it correctly.  

 

Best

Sorry my bad I forgot the parentheses at the end of the condition.  It should be current.comments.changes()

I will update my original response.

nyrguy45
Kilo Contributor

Hello Brian,

 

Thanks again for the quick response, but it still did not work.


See some examples below, of what I am trying to accomplish

find_real_file.png

 

find_real_file.png

 

I was under the impression that additional notes in the sc_task would populate the RITM activities and then send a notification to the requestor with the additional notes.

If I am incorrect i apologize for wasting your time.

Best,