- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2019 07:41 AM
Hello - I'm not sure if this is a bug or just expected behavior. I couldn't find anything about it in the community, so I'm just going to assume it's expected. Whenever a work note is entered by the system (for example, through a business rule), the activity log in the INC or TASK shows the name of the person that triggered the work note. So someone reading through an activity log will assume that someone manually entered that note, even though it's really system generated. Is there any way to change this so that the work note says something like "system" or "Service Now" -- anything but an actual person's name? Thanks in advance.
Solved! Go to Solution.
- Labels:
-
Service Desk

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2019 08:13 AM
Also, you may want to experiment with this if that doesn't work:
current.comments.setJournalEntry('Thank you for contacting TEST', 'admin');
Using that as an example.
Oh and also...I see A issue....
You're basically double-dipping with the impersonate....by having:
var myUser = gs.getSession().impersonate("71478d6c4f649e002de27bcd0210c74a"); //sysID for FJ
and then having this
gs.getSession().impersonate(myUser);
later in the script...so you're causing some issues with the impersonate function.
You'd need to just set the myUser variable to the sys_id of the user....THEN when you use getSession().impersonate later...the variable that's there is just the sys_id...instead you're like running a function in a function...hence why there's probably issues.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2019 07:57 AM
Hi,
Here is thread where there is a similar question and they have 2 different solutions that could work.
Please look here: https://community.servicenow.com/community?id=community_question&sys_id=26498725db5cdbc01dcaf3231f96...
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2019 02:13 PM
Let me know if you need any further assistance with this.
If my reply helped guide you to a resource that was Correct, if you don't mind, please mark it as Correct.
Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2019 07:08 AM
Thank you Allen. I'm trying to do this on an inbound email action, a variation of the OOB script called Update Incident (BP). Our modified version of this script adds a work note & comment to the INC when the user is requesting that it be reopened. That portion of the code looks like this:
if ((email.subject.toLowerCase().indexOf("please reopen") >= 0 || current.state == "6") && current.state != "7") {
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
current.state = "2";
current.work_notes = "The caller did not feel that this issue was resolved";
Based on information I found in this thread and in the link you provided, I added the impersonation script like this:
var myUser = gs.getSession().impersonate("71478d6c4f649e002de27bcd0210c74a"); //sysID for FJ
if ((email.subject.toLowerCase().indexOf("please reopen") >= 0 || current.state == "6") && current.state != "7") {
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
current.state = "2";
gs.getSession().impersonate(myUser);
current.work_notes = "The caller did not feel that this issue was resolved";
However, the work note (and comment) still shows the name of the user who triggered the script. What's interesting, though, is that the email that is sent as a result of the comment shows the name of the person we're impersonating -- somewhat odd. So in summary, in the INC the comment and work note show the user's name, the email shows the impersonator's name.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2019 07:15 AM
Hmm...I'd imagine that's because you aren't updating the record until the end.
You could try to do multi-updates within...like set a current.update(); right after the comment, and then another after the impersonate and work-note entry.
Try that?
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!