When you are making SOAP web service requests in ServiceNow, you can receive a lot of records returned and all columns available. This article discusses how to limit rows returned and how to limit columns shown, so that you just receive the data you are interested in.
How to limit records returned
For an example, if I am querying the incident table and I just want to find incidents in states of 1, 2, and 4. You can use the __encoded_query tag to as your filter. You can use other ways of achieving this as well, however I find the __encoded_query tag to be really helpful. If you are unfamiliar with encoded queries, the ServiceNow Wiki has great information on the topic.
ServiceNow Wiki - Encoded Query Strings
Now to use encoded queries in this example, it would be like this
WDSL: http://<yourinstance>/incident.do?WSDL
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inc="http://www.service-now.com/incident"> <soapenv:Header/> <soapenv:Body> <inc:getRecords> <__encoded_query>stateIN1,2,5,8</__encoded_query> </inc:getRecords> </soapenv:Body> </soapenv:Envelope>
How to limit columns returned
In this same example, finding incidents in states of 1, 2, and 4, and you only want to see certain columns. You can use the __exclude_columns tag to limit columns returned.
WDSL: http://<yourinstance>/incident.do?WSDL
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inc="http://www.service-now.com/incident"> <soapenv:Header/> <soapenv:Body> <inc:getRecords> <__encoded_query>stateIN1,2,5,8</__encoded_query> <__exclude_columns>activity_due,approval,approval_set,delivery_plan,delivery_task,expected_start,order,upon_approval,upon_reject</__exclude_columns> </inc:getRecords> </soapenv:Body> </soapenv:Envelope>
Hope that helps with your web service requests.
Mike