Corey Babka No Comments

I’m a huge fan of “My” style views.  However, what do you do if you have multiple user fields on a form.  Maybe a “outside rep, inside rep, engineer” type of situation?  Had a similar case with a client where we had multiple users on an opportunity.  Not just the owner, but OTHER users which we wanted to see these opportunities when on the “My Opportunities” type of view.  So, we created a formula checkbox which turns true when the user is listed in any one of the fields.  Here’s the code for the formula:

    IF(   Owner.Id   = $User.Id ||
     Salesrep__r.Id  = $User.Id ||
     Salesrep_Add_l__r.Id = $User.Id ||
     Sales_Rep_Additional_2__r.Id = $User.Id ||
     Engineer__r.Id = $User.Id ||
     $UserRole.Name = "Sales Manager"
    , TRUE, FALSE)

It’s long IF/THEN formula, but it’s basically evaluating if the current user is in the rep1, rep additional, the rep2 additional field, or engineer field.  I won’t go into how you make the formula field as that’s pretty straight forward.

Once you’ve got this, just change the “My Opportunities” view to be “All opportunities” but where the field is TRUE (in the image below, we just changed the “opportunities” module to “projects”, hence the difference).