Specifying fields in CSV export

finlay
Kilo Explorer

Hi,

I'm pretty new to developing with ServiceNow so any pointers on this one would be much appreciated. I'm creating a Google Apps Script writing a script that needs to be able to do an HTTP request to pull out a CSV of a search on Service Now. I have it working, however the CSV that is downloaded always contains the fields that I have set up in my dashboard when I log in through the web. For example, if in the web console, I have customised it to show me the state of a ticket and the date it was opened, that's what is outputted onto the CSV.

Below is an example of the URL I'm putting in requests, if you've any pointers on how to specify which fields to include, that would be much appreciated. Thanks!

https://INSTANCE.service-now.com/task_list.do?CSV&sysparm_query=sys_class_name%3Dchange_request%5Eactive%3Dtrue%5Estate!%3D-50%5Ecompany!%3Df66b14e1c611227b0166c3a0df4046ff&sysparm_first_row=1

6 REPLIES 6

CSV is the format I need it in I'm afraid


jarodm
Mega Guru

Although I couldn't find it in any documentation, sysparm_fields (from the REST Table API) works for me when using the CSV web service.



CSV Docs: CSV Web service parameters


Table API Docs: Table API - GET /now/table/{tableName}



e.g.


/sys_user.do?CSV&sysparm_query=active=true&sysparm_fields=employee_number,active,email,first_name,last_name,phone