IsCurrentUser

We needed a custom app to track an employee awards program.  All employees are encouraged to nominate co-workers who have wow’d them.  The nomination process had involved pieces of paper floating around the office waiting on approvals in special colored inboxes.  It should come as no surprise that forms got misplaced or delayed.

With the help of my colleagues, we created a custom app in Salesforce.  The app is one object, the nomination, with approval processes and validation rules.  The nomination object has two user lookup fields: one for the nominee and one for the nominator.  These fields are necessarily independent of the record creator and the record owner for a myriad of convoluted reasons.

PROBLEM:  I can’t create a Custom View to show a user only their nominations (meaning the nominations they’ve written up to award co-workers).  The “My Record” functionality is based solely on ownership of the record.  There had to be a way to make this thing work without giving everyone access to the “All Nominations” view.

SOLUTION: I created a formula field that evaluated to “1” if the nominator was the same as the current user.  I cleverly called the field “IsCurrentUser”.  Here’s my formula:  IF(Nominator__r.Username = $User.Username, 1, 0)

When a user logs in and goes to the “My Nominations” view they see only records for which they are the nominator because the view filter criteria look like this: “IsCurrentUser equals 1”.  There will only be a total of 1200 records per year for this object, so the evaluation time isn’t onerous.

I have to say, I was pretty proud of myself for this one. Now I can better leverage the lookup relationship to the User object in all my custom apps.

Advertisements

4 Responses to IsCurrentUser

  1. Rhonda Ross says:

    What a FANTASTIC idea!

  2. Pingback: Entering Old Data Into A Deployed Object « Amber Neill – Salesforce Administrator

  3. Pingback: Documenting Custom Apps with ScreenSteps « Amber Neill – Salesforce Administrator

  4. cropredysfdc says:

    Brilliant; solves a problem for me with similar characteristics

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: