Is there a way to change the author of a comment in the activity log?

Dubz
Mega Sage

Hi All

I'm creating incidents via REST and i want the comments added to be listed as added by the person, not the web service user used in the integration.

I've tried gliding into the sys_journal_field table and inserting a new record with all the details i want but this doesn't work, comment is added the the author is still me.

function addComment(record,caller,comments){
var gr = new GlideRecord('sys_journal_field');
gr.initialize();
gr.name = 'incident';
gr.element = 'comments';
gr.element_id = record;
gr.sys_created_on = gs.nowDateTime();
gr.sys_created_by = caller;
gr.value = comments;
gr.insert();
}

I've also tried setJournalEntry() but i get the same result:

gr['comments'].setJournalEntry(comments,caller.name);

Is there a way of doing this? I feel like setJournalEntry should work since it literally says that's how it works on the developer site but it doesn't, which is annoying.

1 ACCEPTED SOLUTION

arielgritti
Mega Sage

Hello David

Maybe this can help you. Impersonate like another user and put the comment

var gr = new GlideRecord("incident");
gr.addQuery("number", "<<incNumber>>");
gr.query();
if (gr.next()) {
	var myUser = gs.getUserDisplayName();
	var UserSysId = '45365ed5dbfe2600b1ff73200f961967';
	var impUser = new GlideImpersonate();
	impUser.impersonate(UserSysId);
	gr.comments = ' - Another user comment';
	gr.update();
	
}

 

You can modify this script to update the journal

 

Please, mark correct, useful or bookmark if I helped you

Thanks

Ariel

View solution in original post

3 REPLIES 3

arielgritti
Mega Sage

Hello David

Maybe this can help you. Impersonate like another user and put the comment

var gr = new GlideRecord("incident");
gr.addQuery("number", "<<incNumber>>");
gr.query();
if (gr.next()) {
	var myUser = gs.getUserDisplayName();
	var UserSysId = '45365ed5dbfe2600b1ff73200f961967';
	var impUser = new GlideImpersonate();
	impUser.impersonate(UserSysId);
	gr.comments = ' - Another user comment';
	gr.update();
	
}

 

You can modify this script to update the journal

 

Please, mark correct, useful or bookmark if I helped you

Thanks

Ariel

Thanks Ariel that works really nicely! It puts the caller in as all the other system fields on the form as well which is a nice little bonus 🙂

Hi David

Thank you ... It's an honor for me to help you.

Ariel