Query activity log of INC records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 10:07 PM
Hello,
I have tried several query iterations of identifying information within the activity log of records on the incident table but to no avail.
What I am looking to achieve is to identify records that had a certain assignment group at any point within the life cycle of the ticket.
Has anyone done something similar to this, if so any example scripts?
thanks!
Jake
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 10:29 PM
Hello @Jake Golden ,
Please glide "sys_history_line" table and use this EncodedQuery("set="+sys_id_of_record+"^label=Assignment group");
Mark ✅Correct if this solves your issue and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 10:34 PM
Hello, the journal entries contain only the comments, but not the activity.
You can query 'sys_history_line' for that. See the script example below:
var grHistoryLine = new GlideRecord('sys_history_line');
grHistoryLine.addQuery('label', 'assignment group');
grHistoryLine.addQuery('new', 'Hardware');
grHistoryLine.query();
while(grHistoryLine.next()){
gs.info(grHistoryLine.getDisplayValue('set')+ ': '+ grHistoryLine.getValue('set'));
}
Result of that is:
Whic is exactly what I expect:
Hope it helps.
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 11:54 PM
@Jake Golden if your issue is resolved, please mark an answer Correct. This way the thread will be closed and it will help other users too. Also, this is a good practice to say Thank you to someone who has invested time to help you.
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024