Query activity log of INC records

Jake Golden
Tera Expert

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

3 REPLIES 3

Harsh_Deep
Giga Sage
Giga Sage

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

 

Martin Ivanov
Giga Sage
Giga Sage

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:

MartinIvanov_0-1698298435491.png

Whic is exactly what I expect:

MartinIvanov_1-1698298475938.png

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

@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