- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2021 09:52 PM
I am able to fetch the incident details via servicenow incident api but couldn’t get the sla percentage of that particular incident . Is there any service now api where we can get the incident sla percentage returned along with other incident details ( status, assigned , etc ). Please suggest
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2021 11:46 PM
Hello Jeya, I think you should query the task_sla table with the "now Table API" here is a sample python script from REST API Explorer:
#Need to install requests package for python
#easy_install requests
import requests
# Set the request parameters
url = 'https://yourInstance.service-now.com/api/now/table/task_sla?sysparm_query=task%3D97114c1cdbb2fc10ecec1a4813961921&sysparm_display_value=all&sysparm_limit=1'
# Eg. User name="admin", Password="admin" for this code sample.
user = 'admin'
pwd = 'admin'
# Set proper headers
headers = {"Content-Type":"application/json","Accept":"application/json"}
# Do the HTTP request
response = requests.get(url, auth=(user, pwd), headers=headers )
# Check for HTTP codes other than 200
if response.status_code != 200:
print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
exit()
# Decode the JSON response into a dictionary and use the data
data = response.json()
print(data)
This should return the following data:
{
"result": [
{
"pause_duration": {
"display_value": "1 Minute",
"value": "1970-01-01 00:01:00"
},
"pause_time": {
"display_value": "",
"value": ""
},
"timezone": {
"display_value": "Europe/Amsterdam",
"value": "Europe/Amsterdam"
},
"sys_updated_on": {
"display_value": "22.09.2021 08:41:35",
"value": "2021-09-22 06:41:35"
},
"business_time_left": {
"display_value": "0 Seconds",
"value": "1970-01-01 00:00:00"
},
"duration": {
"display_value": "1 Day 19 Hours 32 Minutes",
"value": "1970-01-02 19:32:33"
},
"sys_id": {
"display_value": "49e20c9cdbb2fc10ecec1a4813961934",
"value": "49e20c9cdbb2fc10ecec1a4813961934"
},
"time_left": {
"display_value": "0 Seconds",
"value": "1970-01-01 00:00:00"
},
"sys_updated_by": {
"display_value": "admin",
"value": "admin"
},
"sys_created_on": {
"display_value": "20.09.2021 13:15:41",
"value": "2021-09-20 11:15:41"
},
"percentage": {
"display_value": "1,088.56",
"value": "1088.56"
},
"original_breach_time": {
"display_value": "20.09.2021 17:08:02",
"value": "2021-09-20 15:08:02"
},
"sys_created_by": {
"display_value": "admin",
"value": "admin"
},
"business_percentage": {
"display_value": "1,088.57",
"value": "1088.57"
},
"end_time": {
"display_value": "",
"value": ""
},
"sys_mod_count": {
"display_value": "38",
"value": "38"
},
"active": {
"display_value": "true",
"value": "true"
},
"business_pause_duration": {
"display_value": "1 Minute",
"value": "1970-01-01 00:01:00"
},
"sla": {
"display_value": "Incident OnHold Test",
"link": "https://yourInstance.service-now.com/api/now/table/contract_sla/e643d084dbf6bc10ecec1a4813961971",
"value": "e643d084dbf6bc10ecec1a4813961971"
},
"sys_tags": {
"display_value": "",
"value": ""
},
"schedule": {
"display_value": "24 x 7",
"link": "https://yourInstance.service-now.com/api/now/table/cmn_schedule/38fa64edc0a8016400f4a5724b0434b8",
"value": "38fa64edc0a8016400f4a5724b0434b8"
},
"start_time": {
"display_value": "20.09.2021 13:08:02",
"value": "2021-09-20 11:08:02"
},
"business_duration": {
"display_value": "1 Day 19 Hours 32 Minutes",
"value": "1970-01-02 19:32:33"
},
"task": {
"display_value": "INC0010067",
"link": "https://yourInstance.service-now.com/api/now/table/task/97114c1cdbb2fc10ecec1a4813961921",
"value": "97114c1cdbb2fc10ecec1a4813961921"
},
"stage": {
"display_value": "In progress",
"value": "in_progress"
},
"planned_end_time": {
"display_value": "20.09.2021 17:09:02",
"value": "2021-09-20 15:09:02"
},
"has_breached": {
"display_value": "true",
"value": "true"
}
}
]
}
so there you have access to the fields "business_percentage" and "percentage". Hope that helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2021 10:20 AM
You're welcome, I would appriciate it if you could mark my answer as correct 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2021 03:52 PM
Thank you so much for helping me here. perfect.
One more doubt, is there a way i can combine the incident api (https://servicenowinstance/api/aelim/incident/) and task api (calculating the sla) as a single result json result set?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2021 12:05 AM
You're very welcome 🙂
Unfortunatly I'm not aware of any OOTB API that would return this as a single json result. You would have to create a Scripted Rest API inside ServiceNow to achieve this.