function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Philip ZimmermanPhilip Zimmerman 

Export a VisualForce Page to CSV - Random appended code

So i have found the numerous articles explaining using 2 pages and one controller to export data to a csv file. I have followed the steps and my created csv file always has the following code appended:

<script type="text/javascript">  SfdcApp.Visualforce.viewstate.ViewstateSender.sendViewstate('https://cs10.salesforce.com' 'ClientPortalCases');  </script>

how do i prevent this code from appearing?  I have seen other people mention this appearing but have never seen a solution.  I also tried exporting to xls but then you get the error message explaining that the extension and the file format don't match.  

Please help!
Tino SeattleTino Seattle
Hi,

Did you by chance ever find a solution to this issue? I'm experiencing it myself and would really like to remove this script tag from the end of the export.

Thanks in advance for any advice!
Tino SeattleTino Seattle
So for anyone else who may be experiencing this issue I found some additional information which may be helpful.

I made my export VF page a public site which seemed to not produce the viewstate script tag at the bottom of the export xml. Then I deactivated the public site and spoofed the account of another user, and again the script tag was not produced at the bottom of the xml. This leads me to believe that there is a setting, either profile or user, which is producing that view state script tag when I export the page under my account.

Note: I do not have Development Mode nor Show View State in Development Mode selected for my account. So I believe finding the actual setting for the developer/system admin account would likely get this tag removed. This is of course assuming there is a setting somewhere or something which can be adjusted to get the same experience the end-user (non-developer) would.

I would really appreciate some additional insight if anyone finds out more.

Thanks!
Tino SeattleTino Seattle
Ahh Ha! Shutting down the Developer Console seemed to resolve the issue. Once the console is closed I was able to then view/download the export without the view state script tag appended to the end of the xml. I tried toggling off a couple of the settings related to view state in the prefences section of the dev console but the only thing that seemed to work was shutting it down completely. 

Hope that helps!
Kacper AugustyniakKacper Augustyniak
HI.
I had the same problem. Removing "core.apexpages.request.devconsole=1" from url worked for me.
Hope that helps.