Pages

Thursday, March 15, 2012

One View to Rule Them All

Scenario:  I was working on customizing a project management app and needed a quick view named "My Projects" that would allow a user to see only the projects in which they were listed as the "Project Manager."

"Project Manager" was a custom User lookup field.  It seemed erroneous to instruct users to create their own views.  There had to be a way that I could create it once and it would provide the correct results for each user.

When you are on the "Create New View" screen, unlike when you are writing a workflow rule, you don't have the ability to create formula based criteria; only the "Filter By Additional Fields" field-operator-value drop downs are available.
IdeaExchange:  https://sites.secure.force.com/success/ideaView?id=08730000000K149AAC




Unfortunately, the Owner of a Project record won't necessarily be the Project Manager, so using the "My Projects" filter won't work (wouldn't it be nice if for any "My" option, a list of User lookup fields would appear that you could select from?)
IdeaExchange:  https://sites.secure.force.com/success/ideaView?id=08730000000grYFAAY


To create one view to rule them all, I ended up creating a formula field that would compare the current user's ID to the Project Manager field and return either 0 or 1.


IF($User.Id = Project_Manager__c, 1,0)


Now that you have your field, any record that you are looking at in which your User ID matches the ID found in the Project Manager field, the "PM is Me" formula field should read "1."


That being so, you can create your view with a single criterion:

That's that!