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
AnshulVermaAnshulVerma 

How to persist values i.e. access values organization wide and user session wide

Hi,

In my application(apex) i want:-

1)Certain values to be accessible to whole organization. Like an array of all countries and states etc. that would be used by all the users.

2) Certain values to be accessible in entire user's session. i.e. once set for one user session would be accessible to all classes when called from the same session. e.g. if I place user's company id in session/cache then it should be accessible across multiple pages(wherever user navigates). something like we do with Cache/Sessions in .NET/Java.

Please reply how to achieve the above mentioned features.

Thanks in advance,
A.V.
dchasmandchasman
Today the most straightforward answer to #1 would be to use custom objects. In a future release force.com will be introducing something that will be a better fit for #1.

If you need to have this user session state traverse accross visualforce and non-visualforce pages again a custom object may be your best choice - possibly combining that with a cusomt component to make it easy to drop onto a visualforce page.

My team has been looking into adding support for #2 in visualforce (something along the lines of the way we handle controller viewstate today but separated out from controllers/extensions).
AnshulVermaAnshulVerma
Hi Doug,

As per your comments you mentioned that i solve the issue #1 using custom objects, actually the issue is that i want to persist the data in custom objects in some Arrays or Lists that would be persistent and available to all organization users; without having to fire SOQL queries again and again for each user for this kind of task. Some data that is always same for all the users (as in my earlier e.g. countries-states). So is there any technique, how this can be achieved.

Regards,
A.V.
London BenLondon Ben
AV...

I may be missing something here - but I see no reason that you couldn't put your values into a js array - contained within a static resource?
AnshulVermaAnshulVerma
Hi,

I don't want to persist the data in a JS array. i want to persist the data in an apex array throughtout the application. Suppose I have an array arrCountries[] i want to fill data into it only once and all the users of my organization should be able to access the same data.

Regards,
A.V.
sunilkbansalsunilkbansal

Hello Dough,

 

Is there anmu update on the #2 from the Original post, session management like .Net/Java?

I was also looking session management like .net/Java o store some info in Apex bvariables which should be avilable to a user for the whole session.

 

E.g. I make a SOQL to fetch the User Profile Name (not profile id), and want to store this profile name somewhere in session or cache, so that next time I need User's Profile Name. I do not need to make SOQL to fetch the same. I should be able to access it from session/cache.

 

Thanks,

Sunil