- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2023 11:25 PM
Hi Team ,
How to check ,how many incident tasks are closed for respective incident using script
Please guide me with best practice
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2023 11:43 PM
Hey @String ,
You can use the following script for finding the number of closed Incident Tasks for an Incident.
//incident_task is the table name for Incident Task table
var target = new GlideRecord('incident_task');
//replace with incident=sys_id of your incident
//states 3,4,7 correspond to closed complete, closed incomplete & closed skipped respectively
target.addEncodedQuery("stateIN3,4,7^incident=077b6755dbd26c10a6a84de239961911");
target.query();
//getRowCount() returns the number of records returned by the query
gs.info("Number of open Incident Tasks are = " + target.getRowCount());
I would suggest substituting the fields with your data and running it in the 'Scripts - Background' module.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2023 11:43 PM
Hey @String ,
You can use the following script for finding the number of closed Incident Tasks for an Incident.
//incident_task is the table name for Incident Task table
var target = new GlideRecord('incident_task');
//replace with incident=sys_id of your incident
//states 3,4,7 correspond to closed complete, closed incomplete & closed skipped respectively
target.addEncodedQuery("stateIN3,4,7^incident=077b6755dbd26c10a6a84de239961911");
target.query();
//getRowCount() returns the number of records returned by the query
gs.info("Number of open Incident Tasks are = " + target.getRowCount());
I would suggest substituting the fields with your data and running it in the 'Scripts - Background' module.