How do i get the breach time, SLA due field says unknown. How can I fix this?

CG4
Kilo Contributor

Hi. 

I'm trying to get a value for how long the SLA has until breach, nor when is it due. With python 3 and pysnow (link to documentation), I can pull all the fields of a ticket in a dictionary(similar to a JSON object with keys and values). 

Here are the ticket fields I found:

  • made_sla, in my testing this one always has a "true" value, whether the SLA is breached, in progress, or completed. Is this normal?
  • sla_due, which is empty even though I have set up my SLA time as five minutes for testing. 

From form layout configuration I found the SLA due field, which in the test ticket says 'UNKNOWN'. I assume this field is the same as sla_due which returns an empty string.

How can I get the value for "time left" or "breach time"?

Do I have to hardcode the SLA duration and just pull the creation date?

Did I miss anything in the SLA config? (screenshots attached)

find_real_file.png

find_real_file.png

I'm also including a list of the fields pysnow pulls from the ticket, for reference.

parent
made_sla
caused_by
watch_list
upon_reject
sys_updated_on
child_incidents
hold_reason
approval_history
number
resolved_by
sys_updated_by
opened_by
user_input
sys_created_on
sys_domain
state
sys_created_by
knowledge
order
calendar_stc
closed_at
cmdb_ci
delivery_plan
contract
impact
active
work_notes_list
business_service
priority
sys_domain_path
rfc
time_worked
expected_start
opened_at
business_duration
group_list
work_end
caller_id
reopened_time
resolved_at
approval_set
subcategory
work_notes
short_description
close_code
correlation_display
delivery_task
work_start
assignment_group
additional_assignee_list
business_stc
description
calendar_duration
close_notes
notify
service_offering
sys_class_name
closed_by
follow_up
parent_incident
sys_id
contact_type
reopened_by
incident_state
urgency
problem_id
company
reassignment_count
activity_due
assigned_to
severity
comments
approval
sla_due
comments_and_work_notes
due_date
sys_mod_count
reopen_count
sys_tags
escalation
upon_approval
correlation_id
location
category

Thank you in advance.

1 ACCEPTED SOLUTION

Community Alums
Not applicable

I believe those are legacy fields that are no longer in use. 

You're going to want to pull that detail from the task_sla table - it's possible (and common) to have more that one SLA record per incident though (OLAs/Vendor SLAs etc) - so you'll need to make sure you're pulling the right one. 

 

You can then see the actual time left, breach time, etc: 

View solution in original post

3 REPLIES 3

Community Alums
Not applicable

I believe those are legacy fields that are no longer in use. 

You're going to want to pull that detail from the task_sla table - it's possible (and common) to have more that one SLA record per incident though (OLAs/Vendor SLAs etc) - so you'll need to make sure you're pulling the right one. 

 

You can then see the actual time left, breach time, etc: 

Thank you. I'll look for the task_sla table.

CG4
Kilo Contributor

Solved, but an update to explain the solution.

# This connects to servicenow

c = pysnow.Client(instance='instance', user='user', password='password')

# This pulls the table

sla = c.resource(api_path='/table/task_sla')

You can then iterate through it with a for loop. each element is a python dictionary.