- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2018 05:22 AM
Hi All,
I've recently setup a business rule to transfer any additional comments from the RITM to the SC_Task activity which works great. This was something that I found on the community. I am now looking to transfer SC_task comments back to the RITM activity but cannot get it to work. This is what I have got so far
Before Business rule
Insert and update ticked
Condition - current.comments.changes()
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);
Any help would be greatly appreciated.
Thanks,
Matt
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2018 05:38 AM
This question comes up quite frequently in the community. I recommend you do a search to see what others have done. It's pretty much the same solution every time.
In any case, you want to write an AFTER business rule on the sc_task table. Your user lookup is unnecessary since the person making the comments is the same as the person logged in, so you can add that to the condition. Note: this code has not been test.
Name: Copy comments
Table: Task (sc_task)
Insert: true
Update: true
Advanced: true
Condition: current.comment.changes() && gs.getUserID() != current.request.requested_for
Script:
(function executeRule(current, previous /*null when async*/) {
var ritmGr = new GlideRecord('sc_req_item');
if (ritmGr.get(current.request_item)) {
ritmGr.comments = current.comments.getJournalEntry(1);
ritmGr.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2018 05:28 AM
You need to write OnAfter Business rule.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2018 05:38 AM
This question comes up quite frequently in the community. I recommend you do a search to see what others have done. It's pretty much the same solution every time.
In any case, you want to write an AFTER business rule on the sc_task table. Your user lookup is unnecessary since the person making the comments is the same as the person logged in, so you can add that to the condition. Note: this code has not been test.
Name: Copy comments
Table: Task (sc_task)
Insert: true
Update: true
Advanced: true
Condition: current.comment.changes() && gs.getUserID() != current.request.requested_for
Script:
(function executeRule(current, previous /*null when async*/) {
var ritmGr = new GlideRecord('sc_req_item');
if (ritmGr.get(current.request_item)) {
ritmGr.comments = current.comments.getJournalEntry(1);
ritmGr.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2018 02:56 PM
Thanks for the help much appreciated.