function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Adriana SmithAdriana Smith 

Need to hide "create new opportunity" button from certain profiles...

I need to find a way to keep certain users from creating new opportunities, thereby only being able to create them by converting a lead.  We have a sales process that starts with lead creation, and it completely throws off our metrics when an opportunity is created directly rather than through lead conversion.  That being said, one team SHOULD be able to do create directly (even if it's only from the 'clone' button).  SF support said I need custom code for this and I've no clue where to start.  Any help would be appreciated.
Dario BakDario Bak
Hi Adriana, if you don't know how to code, you will probably need a Salesforce Partner to code that for you. Just send me a PM if you need help.
Best,
SalesFORCE_enFORCErSalesFORCE_enFORCEr
You can't hide the button but you can restrict the normal opportunity creation using validation rule which will force users to go through lead conversion process only.
RbnRbn
Hi adriana,

 You can hide the New button functionality at the Profile Levels of these users.(only if all these set of users belongs to a single profile).

Go to Profiles - Click on Object Settings - Opportunities - Edit - And Check the Read checkbox.

Please let me know if it solves your query.

Rgrds,
Rabi

 
Jerun JoseJerun Jose
Hi Adriana,

As Shalabh mentioned, you cannot hide the standard 'New Opportunity' button while the profile has access to create opportunities. The simplest option that I can think of would be to use a validation rule on the opportunity object that is met only during lead conversion (I can't think of an easy way for this). The validation rule can be flexible to fire only for specific profile groups so you can allow opportunity creation for some groups of users.

Last option - Code. You can remove the ability of the profiles to create opportunity records and have an apex trigger which creates the opportunity record when a lead is converted. This will give your desired outcome but comes at a cost of introducing some code elements to your lead conversion process which will limit flexibility in future.
Jerun JoseJerun Jose
Also note that you can build standard reports on converted leads to see the opportunity amounts realized owing to lead conversion. So maybe you need to relook at your reports?
Adriana SmithAdriana Smith
How would a validation rule work if it doesn't run until you save a record, not create?
Jerun JoseJerun Jose
The validation rule will run only on save. So, yes, whenever you use a validation rule, the end user's will know they cannot manually create an opportunity only after they have filled in the information and hit the Save button. This can and does cause frustration with the users, but the industry rolls with this.
Aaron BishopAaron Bishop

Returning to a topic that probably should be resolved by now...

An easy way to do what Jerun and the Salesforce Enforcer were suggesting is to just have a field that is always populated on the Lead and map it to the Opportunity. We do something similar and it looks like this: 

  • Create a custom formula field on the Lead called Lead_Conversion_Id. The formula can simply be "Id" since the Id will always have a value for every lead. 
  • Create a text field on the Opportunity called Lead_Conversion_Id, then go back to the Lead Conversion Mappings and map it. Make sure that this field is not visible to the users you don't want creating Opportunities from scratch so that they can't fill it in when they try.
  • Create a validation rule on the Opportunity that looks like: ISBLANK(Lead_Conversion_Id), which returns an error. Our error tells the user that to keep data consistent, they must create a lead first and then convert it to a loan. 
This will make it so that users can't create an Opportunity from scratch, but can create one from a converted Lead. Yes, it is rather annoying the first time or two because you don't get the error until after you enter the information and click "Save", but users will quickly catch on.
Sam AdlerSam Adler
Hey @aaron b,
Thanks for this logic. Question for you. As you laid it out, the validation rule will prevent everyone in the org from creating an Opportunity from Scratch.  Like the original question above, we only want to prevent Partner Portal users from creating Opportunities from Scratch, but allowing them to create when converting.

How would I update the Validation rule so that this only applies to Partners (I'm guessing we could use a restriction of IF( $Profile.UserType = Partner...), but allows our internal users to create opportunities from scratch.

What would the validation rule look like for this?
Aaron BishopAaron Bishop
Yep, that's exactly it. We do a similar thing where we make it so that certain profiles can't create the opportunity. The validation rule would be something like:
AND(ISBLANK(Lead_Conversion_Id),$Profile.UserType = "Partner")
This will cause an error if there is no Lead Conversion Id and the UserType is Partner.
Sam AdlerSam Adler
Thanks, This is the validation that ultimately worked:

AND(ISBLANK( Lead_Conversion_ID__c ), ISPICKVAL($Profile.UserType, "PowerPartner"))
Unique TwoUnique Two
So close for me, for existing opportunities it is throwing the validation error though when the user goes to edit an existing opportunity because the field is blank of course.  how to over come that in the formula?
Aaron BishopAaron Bishop
@Unique Two, not sure if this is the best way to do this, but my first thought is that you can add another condition based on the CreatedDate. Something like:
AND(
    ISBLANK( Lead_Conversion_ID__c ),
    ISPICKVAL($Profile.UserType, "PowerPartner"),
    CreatedDate > {{date you created the rule}}
)
Unique TwoUnique Two
For those playing at home this has resolved  the issue of any existing opportunities weren't able to be edited with the above formula so this helps then after the date you created the validation rule.
The formatting of the date formula is as follows..

AND(
ISBLANK( Lead_Conversion_Id__c ),
DATEVALUE (CreatedDate) > DATE (2021,10,11))