sys_journal_field no state changes

xlarge74
Tera Expert

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

2 ACCEPTED SOLUTIONS

Nilesh Pol
Tera Guru

@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);
}

View solution in original post

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.

View solution in original post

7 REPLIES 7

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.

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 

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