How to post comments as system instead of current user in scoped application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hello Team,
I am trying to post comments via script in scoped application but in the activity stream it is showing as Logged in User i wanted to show it as system i cant use setJournalEntry() method in scoped application script How to achieve this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
58m ago
you can create a workflow on that table in your scoped app and give Wait for Duration with 2-3 seconds
Once that Wait for Duration is done you can use script to set comments and it will come as System user
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
54m ago - last edited 50m ago
This is going to depend on the nature of the script you are running.
If you are running a client side script then I don't believe there is a way to perform the action as the System user. I think you would have to create an event caller to queue an event to trigger a server side script/flow that you could set to run as/by the system user.
If you are in a workflow action or server side script (not a script include) then you should have the option to set it to run as system.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
44m ago
There are a couple of options I can think of off the top of my head, but my first question is why do you want to add a worknote as system instead of the user who triggered the creation of that worknote?
- You could put your script in a Script Action[sysevent_script_action] then use an Event to trigger it.
- You could create a Flow that runs as System(set in the Flow's properties) and use the "Add Worknote" action under ITSM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8m ago
Hi @Swathi P ,
This is a common challenge in ServiceNow scoped applications because the setJournalEntry() method is restricted to global scope, and by default any journal/comment updates will appear as the logged‑in user.
You can achieve system‑authored comments in a scoped app:
Options to Post Comments as "System"
- Use GlideSystem.addInfoMessage() (for UI feedback only)
- This shows messages to the user but does not persist in the activity stream.
- Useful for temporary system notices, but not for audit trail.
2. Insert into sys_journal_field directly
- In scoped apps, you can manually insert a record into the sys_journal_field table.
- Example:
(function executeRule(current, previous /*null when async*/) {
var journal = new GlideRecord('sys_journal_field');
journal.initialize();
journal.element_id = current.sys_id; // target record
journal.name = current.getTableName(); // table name
journal.element = 'comments'; // journal field
journal.value = 'System generated comment';
journal.sys_created_by = 'system'; // override user
journal.insert();
})();
- This bypasses setJournalEntry() and directly creates the journal entry with sys_created_by = system.
3. Use a Background Script / Scheduled Job
- If you run the script via a background job or scheduled job, the sys_created_by will automatically be system.
- Example: Scheduled Script Execution that adds comments to records.
4. Business Rule with gs.getUserID()
- You can temporarily impersonate system by setting sys_created_by explicitly when inserting into sys_journal_field.
- Scoped apps allow you to set that field if you’re inserting manually.
Important Notes
- Directly manipulating sys_journal_field is not officially recommended by ServiceNow, but it’s the only way in scoped apps when setJournalEntry() is unavailable.
- Always ensure audit integrity: document why the system is posting comments.
- If you want the comment to appear visually identical to system‑generated ones, set:
- sys_created_by = "system"
- value = "Your message"
So the practical solution in scoped apps is: manually insert into sys_journal_field with sys_created_by = system. That way, the activity stream shows it as posted by "System" instead of the logged‑in user.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Best,
Anupam.
