- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 08-08-2019 06:48 AM
There are several good solutions out there that help configure the copy of comments from RITM to TASK...which are all good and working, however several customers are facing a situation where the Customer has access to the Request record via portal and the fulfiller is required to update and complete tasks. This becomes even more complicated when an Order Guide is used where a single request can spawn multiple request items and tasks (think on-boarding). This means that the system cannot really be configured to redirect the user from the catalog item to the request item when submitting a request from the portal as there could be many RITM's to one REQ.
To make sure comments are copied from the Request record down to all Tasks and that responses on individual tasks are written back up to the request WITHOUT DUPLICATION, consider the following two business rules:
Copy comments from Task to Request
- TABLE: sc_task
- WHEN: Before Update
- CONDITION: current.comments.changes() && current.comments.getJournalEntry(1).indexOf("Comments added from:") == -1;
(function executeRule(current, previous /*null when async*/) {
var customer = gs.getUserID();
var gr = new GlideRecord('sc_request');
gr.addQuery('sys_id', current.request.sys_id);
gr.query();
while(gr.next()) {
if(gr.requested_for != customer)
gr.comments = "Comment added from : " + current.number + " | " +current.request_item.cat_item.name + "\n >>> " +current.comments;
gr.update();
}
})(current, previous);
Copy comments from Request to all Tasks
- TABLE: sc_request
- WHEN: Before Update
- CONDITION: current.comments.changes() && current.comments.getJournalEntry(1).indexOf("Comments added from:") == -1;
(function executeRule(current, previous /*null when async*/) {
var agent = gs.getUserID();
var gr = new GlideRecord('sc_task');
gr.addQuery('request', current.sys_id);
gr.query();
while(gr.next()) {
if(gr.assigned_to != agent)
gr.comments = "Comment added from: " + current.number + "\r\n" + "> " + current.comments;
gr.update();
}
})(current, previous);
Some things to note about this solution:
- If the task is not assigned to an individual, the rules still work, but comments added to the task will "repeat" themselves on the request. It is assumed that the person entering comments is the person that the task is assigned to
- Comments added to the request are copied to all tasks...even closed ones. You may consider updating the addQuery on the sc_request rule to not copy comments to closed tasks.
Special thanks to Michael Fry and Paul Morris. This solution is a combination of both of their suggestions on the community