- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2018 02:54 PM
Hello guys,
I need the history of changes for the Assigned to Field, I am working in the sandbox and enabling auditing for the incident table as suggested here:
https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/administer/security/task/t_EnableAuditingForATable.html
Yields nothing when I make the API call. Querying sys_dictionary , sys_audit, sys_history_line or sys_history does not work either. I dont know what to do, im using python. Here is one example, the requests that come back are empty or invalid, how else can I do this? Is there a way to get the " Field changes " table? thank you!
# Set the request parameters
url = env + 'api/now/table/sys_audit/' + sys_id
# Set proper headers
headers = {"Content-Type":"application/json","Accept":"application/json"}
# Do the HTTP request
response = requests.get(url, auth=(user, pwd), headers=headers ,data="{\"fieldname\":\"assigned_to\"}")
# 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()
return data
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2018 01:29 PM
Hi Mario,
Could you set my response to correct if this query retrieved the correct details for you?
Cheers,
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2018 10:18 AM
this does not work unfortunately, I dont know what else to do.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2018 10:29 AM
Can you remove the below marked in bold and try
response = requests.get(url, auth=(user, pwd), headers=headers)
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2018 10:21 AM
Hi Mario,
I believe you're looking for the sys_history_line, but you'll have to do some dot-chasing to access the correct attribute. Try performing a table query with sysparm_query=set.id=${incident_id}
Using the Table API, this would come out to a GET call to
https://INSTANCE_NAME.service-now.com/api/now/table/sys_history_line?sysparm_query=set.id=05f7875cdb982b00f2e4d2984b961966
Possibly with an addition on the query to only look for assigned_to entries, which could be arranged by appending ^field=assigned_to to the end of the URL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2018 01:29 PM
Hi Mario,
Could you set my response to correct if this query retrieved the correct details for you?
Cheers,
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2018 03:05 PM
The response returns a result object and then you can check if the field modified is "assigned_to" and parse it like this:
for ticket in getServiceAssignedToHistory(sys_id goes here)["result"]:
if(ticket["field"] == 'assigned_to'):
print("old user :")
print(ticket["old"])
print("new user")
print(ticket["new"])
Thank you very much! It works now!