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

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

Rohit  Singh
Mega Sage

Hi @xlarge74 ,

 

Please make sure that from the Filter activity Incident State is selected. If not then select it and then see if state changes are showing in Activities or not. Refer Snip Below.

 

RohitSingh_0-1743162733978.png

 

If my response helped, please hit the Thumb Icon and accept the solution so that it benefits future readers.

 

Regards,
Rohit

 

OlaN
Giga Sage
Giga Sage

Hi,

All changes made (that are audited) are captured in the sys_audit table.
This table is usually huge, due to the large number of changes made in any ServiceNow instance.
What are you trying to do ?

xlarge74
Tera Expert

hello thanks for the answers... 

 

i will try  your hints on monday

 

PS: i´m on alm_hardware  and i try to find out if an asset is set to "in use" the second time. afterwards i have to do some changes 

 

kind regards

oliver