Wednesday, June 29, 2011

Tips&Tricks: Records Created By the Current User

Here's a little formula that I came up with that comes in handy when you need to create reports and dashboards that display things like Activities, Cases, Leads, Opportunities, etc that were created by one user, but might now be owned by another user.
Unfortunately the built-in Salesforce "My..." and "My Team..." filters only reference the record Owner field, so you're forced to clone reports and edit the Created By filter (making the Running User pretty much useless)

Until now....

Here's what you do:

Create a custom field on the objects that you need to track CreatedBy (User).
Field Name: CreatedBy$User
Datatype: Formula
Return Type: Number, 0 decimals
Formula: IF(CreatedById = $User.Id , 1, 0)

Now just add a simple filter:
Field: CreatedBy$User Operator: [equals] Value: 1

to your reports and now use the Running User to create Scheduled Reports and Dashboards that display anything a user created. Now if you need to create a new "Created By... Dashboard" all you have to do is clone the Dashboard and change the Running User (no more cloning and editing reports for each user)

it also works with List Views too!


3 comments:

  1. SteveMo, do you have any advice on using similar logic to create a sharing rule? I am using a formula field labeled "Belongs to Logged in User" and it reads "Yes" if the current user's name is in a certain field. IF formula fields could be used in criteria-based sharing, this would be a no-brainer. But they're not allowed. Ideally, I would manage record editing based upon whether the Belongs to Logged in User Field = Yes.

    ReplyDelete
  2. This solved a major problem for me! Thanks for the tip.

    ReplyDelete