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
3 weeks 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
3 weeks ago - last edited 3 weeks ago
I am updating comments from Business rule and Flow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks 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
3 weeks ago
I am already running the flow as system user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks 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.