get history of changes for an incident field (Assigned To)

Mario Landa
Kilo Explorer

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
1 ACCEPTED SOLUTION

Hi Mario,

Could you set my response to correct if this query retrieved the correct details for you?

Cheers,

Steve

View solution in original post

9 REPLIES 9

SanjivMeher
Mega Patron

Can you change the 2nd line to below and try

 

url = env + 'api/now/table/sys_audit/?sysparm_query=documentkey=' + sys_id

If it worked kindly mark my response correct

Mario Landa
Kilo Explorer

What goes in sysparm_query=documentkey , Whats the document key?

documentkey stores the sysid of the incident