script to Fetch Incident state from task_sla table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2023 10:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2023 10:49 AM - edited 03-21-2023 11:16 AM
I have tried making a GlideRecord in my PDI as mentioned below:
var gr = new GlideRecord("task_sla");
gr.get("6917ac280b8632007518478d83673ab9");
gs.info(gr.task.state);
you can fetch the state of incident using "gr.task.state" or "(gr.task.state).getDislayValue()" as task is the reference field so you can perform dot walking to get the state.
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2023 11:09 AM
You can run a background script to do this. See documentation here: Using Scripts - Background
The script below just looks at the first record of task_sla's where the stage is "in progress"
var gr = new GlideRecord('task_sla');
gr.addEncodedQuery("stage=in_progress");
gr.query();
if(gr.next()){
gs.log("The incident " + gr.task.number + "'s state is " + gr.task.state.getDisplayValue());
}
Results:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2023 01:24 PM
Hi @Roshin Chandra ,
What is your requirement since you want a script to fetch incident state from task_sla? Could be there where are more standardized solution than custom script?
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up,
Best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 01:18 AM
My requirement is to send notification to manger daily regarding all the sla breached tickets whose status is not resolved or closed.