Search code examples
javajsonweb-servicesservicenow

How to filter service now incident records based on caller?


I'm using json web service for service-now to query on the incident records. I'm using java and apache Httpscomponents to make calls. There are huge many records in the incident table, but I want to filter the ones which I need to work upon. With some help from the wiki I was able to fetch the records which are newly added. I want to fetch the records called/created by a particular user.

I make calls on the URL of the form below with the myUserName being the caller whose tickets I need to work upon.

https://<instance>.service-now.com/incident.do?JSON&sysparm_action=getRecords&sysparm_query=incident_state=1%5Ecaller=myUserName

The problem is that I'm still getting all the incidents that are new, meaning the sysparm_query=incident_state=1 is working but the one afterwards fail or gets omitted.

Please tell me if my approach is wrong and point me in the direction, or if its a mistake what might be the correction in the URL?


Solution

  • You could also use a query in this form to use the caller_id if you needed to filter on that field instead:

    &sysparm_query=incident_state=1^caller_id.user_name=youruserid
    

    This is useful since it can be employed for other user fields such as assigned_to, etc.