As a consultant, you get a lot of weird requests that make you scratch your head and wonder “can I really do this with Salesforce”, and sometimes even “why the F would they want to do that, that’s ridiculous. Why did you bother signing up for Salesforce, go use Dynamics in DSL traffic or something”.
In this use case, it was the former. The client wanted to calculate a 5% commission value off an Opportunity amount but keep that value private to ONLY the opportunity owner, but also wanted to report off of it by management.
The kicker is, they did NOT want private sharing rules for a lot of valid reasons. So how can you make a custom field private to an individual user, but still reportable by management?
I’m sure for most grizzled Salesforce vets, this is a simple solution, and you’re all already grunting at me, but for those that may be newer to Salesforce, or you’re just damn curious, this is for you.
After some searching through the community, I came up with diddly. As a note, that’s my first go-to. Why recreate the wheel if someone already has a solution, right?
This is what I came up with, tested, and works perfectly:
For those of you who may be weak in formula fu, here is what this formula is doing:
If the opportunity owner is the same as the currently logged in user viewing the record OR the profile name of the person logged in viewing the opportunity is named “Manager” (actual profile name not listed to protect the innocent), then return a value that is 5% of the amount, otherwise if none of the above criteria are met, return nothing.
Thats it. It simply asks:
Are you the opportunity owner?
Are you a manager that has access to this data?
You’re one of those 2? Great! Here’s the commission amount!
If you’re not one of those 2 folks…pound sand, you get NOTHING
I tested this as an admin, a different admin, a general user, the “manager” profiled user, and the opportunity owner. All worked as intended.
One note on this formula is that since it is NOT using hard coded Id’s, it is dynamic and usable in a sandbox. Thanks to all the grizzled vets out there that pounded that into my head.
Hope someone finds value in this! Happy Trails!
Leave a Reply