- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2025 04:43 AM
hi there
i am looking for a possibility to read the activity stream state changes.
I tried with sys_journal field, but i only shows work notes.
is there a table where the state changes form the activity stream are shown?
kind regards
Oliver
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2025 04:51 AM - edited ‎03-28-2025 04:53 AM
@xlarge74 Yes, sys_journal_field table primarily tracks Work Notes and Comments, To specifically track state changes, you should use the sys_audit table, which logs all field changes, including state transitions.
To query and track state changes in a table (e.g., Incident), you can use the following approach:
var auditGR = new GlideRecord('sys_audit');
auditGR.addQuery('tablename', 'incident'); // Specify the table, e.g., Incident, Change Request
auditGR.addQuery('fieldname', 'state'); // Focus on changes to the 'state' field
auditGR.query();
while (auditGR.next()) {
gs.info('State Change: ' + auditGR.new_value + ' from ' + auditGR.old_value);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2025 07:15 AM
I would try to avoid solutions that queries the sys_audit table whenever possible.
Instead you can implement a custom field that counts the number of times an Asset is set to in use (set it by business rule) and take actions when the counter exceeds a certain value.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2025 07:15 AM
I would try to avoid solutions that queries the sys_audit table whenever possible.
Instead you can implement a custom field that counts the number of times an Asset is set to in use (set it by business rule) and take actions when the counter exceeds a certain value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2025 03:46 AM - edited ‎04-01-2025 05:15 AM
hello, i have to go for the query max 1 time, for the older assets.
i tried with this code. i get the sys_id, but there is no output. could you tell me why?
i´m puzzled
kind regards oliver
var activity = new GlideRecord('sys_audit');
activity.addQuery('tablename', 'alm_hardware');
activity.addQuery('documentkey', current.sys_id);
activity.addQuery('fieldname', 'install_status');
activity.query();
while (activity.next()) {
gs.addInfoMessage(activity.oldvalue );
}
i did the same query in the db table, there ist works
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2025 11:54 AM
its working now
i changed a lot of things and i don´t know exactly which one was the trigger 😄
thanks for the invested time
kind regards oliver