Export Report in CSV format using a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2018 10:52 AM
Hi,
I have figured out a script to export report using csv format which is great but i cant export more than 50,000 records
I have tried the logic of looping through and exporting 50,000 records at a time and combine them at the end but specifying a number in sysparm_first_row gets ignored and it always results the first 50,000. Is there any other way around this? I am using powershell if anyone has expertise in that area

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2018 11:51 AM
Since you are directly calling the report, it will give you result based on export limit, even if you pass the first row parameter.
If you are directly querying the table, you may be able to split them. But not sure how you will export it then.
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
01-11-2018 11:55 AM
Yea, the data is grabbed from different tables which is why i am using report so i can get data in one report. So that means there is no way to accomplish this is what i am guessing?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2018 12:02 PM
I think there is not. But wait for response from others. There could be.
One option could be to query the table and just print everything to an email. But then it becomes difficult for them to go through the data in an email. There could be a limit on the email body as well.
Or query everything from the table directly and try exporting it to csv using code. Not sure how feasible it is.
How to export JavaScript array info to csv (on client side)? - Stack Overflow
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
01-11-2018 01:23 PM
Our typical go to for this is to capture and reuse the sys_ids as a filter (where possible). It's an extra step because it may ruin whatever sorting you've already got, but if you're ordering by date it should be pretty much the same.
- add OrderBy (or OrderByDesc) sys_id to the query
- Within the PowerShell (or Bash, for any future readers who may need it) capture the sys_id of the last node that you receive
- resubmit your next request adding a "sys_id > *whatever the last sys_id was*" ( sys_id < for OrderByDesc)
It's not perfect, but hopefully it'll work for you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2018 01:45 PM
That sounds helpful, can you give me an example of the URI for this scenario and that will work with report_template_do also right?
What would the URI look like when we are specifying > sys_id