Skip to content

Commit 5918982

Browse files
Create 01README.md
This ServiceNow Background Script allows you to add comments or work notes to a record on behalf of a specific user.
1 parent 6e1637b commit 5918982

File tree

1 file changed

+44
-0
lines changed
  • Server-Side Components/Background Scripts/Add Comments

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
ServiceNow Background Script – Add Comments on Behalf of a User
2+
Overview
3+
4+
This ServiceNow Background Script allows you to add comments or work notes to a record on behalf of a specific user.
5+
Normally, when comments are added directly via scripts, they appear as the integration user. Using this script, the comment will show the actual user in the Activity Formatter.
6+
7+
This is perfect for Hacktoberfest contributions, demos, or integration testing.
8+
9+
Features
10+
11+
Works directly in Scripts – Background in ServiceNow.
12+
13+
Adds comments or work notes as a specified user.
14+
15+
Can be used for the Incident table or easily adapted for other tables.
16+
17+
Logs success or error messages in the Background Script output.
18+
19+
How to Use
20+
21+
Open Scripts – Background in your ServiceNow instance.
22+
23+
Copy and paste the script.
24+
25+
Update the input variables at the top of the script:
26+
27+
var incidentSysId = 'INCIDENT_SYSID'; // sys_id of the record
28+
var userName = 'john.doe'; // user_name to attribute the comment to
29+
var commentText = 'Your comment here'; // comment content
30+
var journalField = 'comments'; // 'comments' or 'work_notes'
31+
32+
33+
Click Run Script.
34+
35+
Check the Activity Formatter of the record to see the comment added under the correct user.
36+
37+
Example
38+
var incidentSysId = '1234567890abcdef';
39+
var userName = 'john.doe';
40+
var commentText = 'This is my Hacktoberfest comment!';
41+
var journalField = 'comments';
42+
43+
44+
After running, the comment will appear in the Incident’s activity log as if john.doe added it.

0 commit comments

Comments
 (0)