SCTask

yoli1
Tera Contributor

Hello team when adding a close comment to SCTask it show as created by Sytem rather than user creating the comment

yoli1_0-1695400547461.png

7 REPLIES 7

Ah, that is what your looking for 🙂

 

Use it like this:

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

var item = new GlideRecord('sc_req_item');
item.get(current.request_item);
item.comments.setJournalEntry(current.comments.getJournalEntry(1),gs.getUserName()); //Get last journal entry
item.update();

})(current, previous);

 

If needed, you could set a different user_name instead of gs.getUserName()


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

@Peter Bodelier didn't work still showing as System

Ok, then for some reason your BR is triggered by a system update.

 

Try 

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

var item = new GlideRecord('sc_req_item');
item.get(current.request_item);
item.comments.setJournalEntry(current.comments.getJournalEntry(1),current.sys_updated_by); //Get last journal entry
item.update();

})(current, previous);

Or maybe even 

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

var item = new GlideRecord('sc_req_item');
item.get(current.request_item);
item.comments.setJournalEntry(current.comments.getJournalEntry(1),previous.sys_updated_by); //Get last journal entry
item.update();

})(current, previous);

Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.