[ScenarioSolutionIntro ]
[sc:ScenarioSolution ]
[RCNotLoggedInNotAdmin]
[/RCNotLoggedInNotAdmin]
[RCAdmin]
To solve this scenario, I would use field-level security to control access to the Commission field (hide from all except sales admin/system administrator). Then I would create a formula field Commission Display that only displays the commission value if the current user is the opportunity owner.
Note, that field-level security cannot be determined conditionally (e.g. based on record owner). For this reason, it is necessary to create a formula field to conditionally display the value.
[sc:ScenarioSolutionSteps ]
Create the Commission Currency field:
- Navigate to Setup –> Customize –> Opportunities –> Fields.
- Click New (to create a new field).
- Select Currency.
Click Next. - Label “Commission”.
Length 10.
Decimal Places 2.
Click Next. - Remove ‘Visible’ for all profiles except System Administrator.
Click Next. - Click Save.
Create the Commission Formula field:
- Navigate to Setup –> Customize –> Opportunities –> Fields.
- Click New (to create a new field).
- Select Formula.
Click Next. - Enter Field Label “Commission”.
Enter Field Name “Commission_Formula”.
(The naming convention is up to you here. Using the same label will provide a consistent user experience, however the field names cannot be the same.)
Select Currency, Decimal Places 2.
Click Next. - Enter formula: “IF( OwnerId = $User.Id , Commission__c , null)”
Click Next. - Remove field-level security for the system administrator profile (this will prevent the field from being displayed twice).
Click Next. - Click Save.
Formula Logic Explained:
IF( OwnerId = $User.Id , Commission__c , null)
The IF statement takes the following format:
IF( Condition, True Result, False Result)
The condition “OwnerId = $User.Id” determines if the opportunity owner (OwnerID) is the same as the user currently logged in ($User.Id is a global variable). If yes, display the commission amount. If no, display nothing (null).
[box type=”info” style=”rounded” border=”full”]Note: a null result will display an empty field. A result of 0 will display $0.00, implying that the commission was zero instead of simply hidden.[/box]
[/RCAdmin]
Thanks John – got there in the end!
A couple of questions – the OWD had to be set private no? Also, if you hide the other original commission field, how could you later on edit or add to the commission field?
It’s weird that it actually works. By definition, only users with profiles that have access to the original field can see the value of that field on the screens and reports. The formula will run in the context of the user currently logged in. So, even though the user is the owner of a specific opportunity, he/she still shouldn’t be able to see a value from a field that he/she doesn’t have permission to see. I understand that it gives you an option to implement conditional read permissions, but it looks like a potential security hole
That’s a very reasonable assessment and definitely something to consider in your architecture design. You’ll see similar considerations that need to be evaluated when implement custom code as well.
Hi – How we are going to implement a scenario where the managers need to see their reports commission?
Is it possible to achieve this by using just one custom field? How about using one Commission field and have formula to refer to oppty cost * some percentage to calculate commission and use that in the formula?
Hi Dey, I used this and worked fine with only ONE Formula field. That would have been my approach.
IF ($User.Id = Owner.Id, Amount * 0.2 , null)
I guess the “formula” field is not entirely appropiate, since it cannot be manually changed by sales ops as John states: “commission field gets entered by sales operations or by workflow rule”
Anyhow, I believe that most of the times, commisions are calculated instead of manually populated.
Cheers
Spot on – just depends on the scenario
Hi John,
This was a tricky scenario!!
I set the OWD for Opportunities to Public Read Only. Is that correct?
The “Sales reps must have the ability to view opportunities owned by other users (without being able to view the commission on that opportunity)”.
The org wide default will allow the users to view all opportunities, however that won’t take care of the field permissions…
I am getting an error with the formula. The system indicates return the values in “text” the field is selected as formula currency 2 decimals?
If I set to text the field will display the formula instead of the results?
If it is set to text then you will need to convert the numeric value to text in order for the formula to work corrected – I believe the TEXT() function will do that.
Hi John,
Doing this by just one field commision and having this formula:
IF( OwnerId = $User.Id , IF( TEXT(StageName) = “Closed Won”, Amount * 0.15 , Amount * 0) , null)
Will first check if the owner is current user and then check if commision need to be 0 or some amount based on opportunity won or not. Just an opinion.
Yeah that can work if your commission can be calculated in a formula, for sure.
Hi John, awesome explanation of the syntax, very kind of you. I have tested the commission field with my test user and it works fine. The commission value is blank for test user but populated for sys admin.
Frankly, this scenario sucks as you don’t tell us that the commission field is populated “by workflow” or API in the scenario. It’s the only way to hide the input field. Unless you change the ORG defaults and create sharing rules. One would assume that someone has to populate the commission amount and that the field would have to be on the page layout.
If you did tell us then it would have been very interesting challenge,
I think the scenario makes sense:
“Currently, the value is manually entered by the sales admin when a deal is won, as the commission matrix is quite complex and reflects variables not currently captured in Salesforce.
The sales reps should be able to view the commission amount on opportunities that they own, but not opportunities owned by other users. ”
“by the sales admin” being the key in the first sentence, and “view” being the key word on the second sentence (the sales user is not inputting their commission – just viewing; the sales admin would update the actual commission field).
It is a tricky scenario though, I can see how it would be hard to arrive at the solution.
Hi John,
We do need to call the fields individual names, the both show up as new fields on the opportunity page layout. So “my commission” gets added to the Opportunitiy Page Layout, correct? And does it go the the Opportunity Page Layout or the Opportunity (Sales) Layout? I’m taking my test on Thursday, I appreciate your answers to all questions posted this month.
Thanks, Maura
By using field level security, you can have both fields present on any/all of the page layouts. The field level visibility will take care of only showing the field to those that have access.
Hi John,
I think it is required to add a field level security for Sales profile (Inside Sales Team, etc.) for the new commission formula field. This step needs to be added under the heading – Create the Commission Formula field:
Thanks
Remove field-level security for the system administrator profile (this will prevent the field from being displayed twice).
^^ By only removing the system admin, the rest of the profiles should be selected, and the permissions should be set up correctly.
What do you mean by “Remove field-level security for the system administrator profile (this will prevent the field from being displayed twice).”? It’s unclear what the FLS setting should be for the Formula field.
Thanks!!
Munish – you have two commission fields:
1. Commission: this is the raw calculation. This is only displayed for admin types.
2. My Commission (or equiv): this only displays a commission value to the opportunity owner. For other users the field is blank.
The second field can be set to hidden for the admin profiles, so that they do not see two commission fields.
The first field would be set to hidden for non-admins, so that they cannot see the value for all commissions.
I named the formula field “My Commission”. I think that way it’s clearer what the intent is, e.g. if used in reporting. I also left it displayed for system admins, which makes for easier testing.
Nice touch Sue
Since Opportunity is Private security type, users cannot see opportunities created by others.
So if we create a regular field , with R/O privileges to Sales users and Visible / Editable to Admin, doesnt that solve the purpose.
Am I missing something
From the scenario: The sales reps should be able to view the commission amount on opportunities that they own, but not opportunities owned by other users.
If you made the assumption that sales reps would ONLY be able to view opportunities that they owned, you could use OWD (private) to make this the case. I’ve updated the scenario to make this more clear that this is not the case – sales users may be able to see other opportunities (that they do not own).
I think the formula is incomplete because there is no test to confirm the opportunity was won. Perhaps the following would be more accurate:
IF(AND( IsClosed , Owner.Id == $User.Id ), Commission__c ,null)
The idea here is that the commission field would only be displayed to the current user – how that field gets populated isn’t baked into this example, but I understand your point. The assumption would be that the commission field gets entered by sales operations or by workflow rule.