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
AyanHoreAyanHore 

How to pass transient data from one visualforce page to another?

Hi,

I've a link in my visualforce page, which renders the data as Excel. However, post developement, I wanted to do some performance tuning and to reduce the view state size, have declared the list variable (having the complete set of data to be displayed) as transient. As a result, no values are being passed to the next VF page.

As of the moment, I've removed the transient type and it is working fine. However, if there is any way to pass transient values to subsequent pages, it will be very useful as I'm worried about the view state size in case of a huge volume of data.

Thanks...!!

~Ayan
Best Answer chosen by AyanHore
AshwaniAshwani
Transient are not meant for maintaining state. In apex transient variables get set to null after assignment and performing required state. IT is only maintain for a single context thread. 

To pass value from one page to another use non-transient variable. If you have any viewstate issue set that variable to null after you finished with it.

All Answers

Alex TennantAlex Tennant
Are you saving your transient data back to the database in your first page?

If you are then you can pass the Id to your second page and then re-query for the data to access it in your second page.
Anup JadhavAnup Jadhav
I would say if you want to pass data from one page to another then don't declare it transient. Alternatively copy the transient value to a non-transient variable and use that for inter-page communication.
AshwaniAshwani
Transient are not meant for maintaining state. In apex transient variables get set to null after assignment and performing required state. IT is only maintain for a single context thread. 

To pass value from one page to another use non-transient variable. If you have any viewstate issue set that variable to null after you finished with it.
This was selected as the best answer
tsalb_tsalb_
If they are simple strings you can place them into URL params and construct your next page URL that way.