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
woodmanzeewoodmanzee 

private visualforce pages for users

So I've written a Visualforce page that acts as a to-do list, but currently it serves as one to-do list for the entire company that is using the salesforce instance. I want to make it so that each user that logs in has their own to-do list that is only visible to them, AS WELL as having one to-do list for the company. 

 

What would be the best way to do this? Any ideas or examples would be useful. Thanks in advance

bob_buzzardbob_buzzard

What goes into this todo list?  Is it tasks/events or custom objects of your own.

 

If the sharing on these items is private, then a reguar visualforce page will only show the records that the logged in user has access to.  If that's not the case, you'll need a custom controller that uses the UserInfo class and retrieves only those records that are specific to the user (assuming you have a way to determine this). 

 

You may be also able to use a standard visualforce page but then only render the records that match up with the user information exposed by the $User global variable.

woodmanzeewoodmanzee

These are custom objects of my own that are displayed in a list format. 

 

So It'd be ideal if no apex controller were needed - setting the view of these objects to private would solve that? 

Though actually i think I'd want one board to only show the items the user has created, and the other to show company items that anybody can add to. 

 

If I'm not using a custom controller, can I still only display User related records? How can I use the $User variable? The only examples I see are to display the user name

Thanks

bob_buzzardbob_buzzard

Standard visualforce controllers respect the permissions and sharing of the currently logged in user, so for the board that shows the items the user has created, the private sharing model will work.

 

To allow access to company specific items, you'd need to set up sharing rules to make them available to all users.

 

The trick is then to distinguish between those that the user has created and those that are company specific - you should be able to do this via the rendered attribute based on a field in the record.  if you have an attribute on the company wide ones, it should be straightforward.