How to prevent users to select Price Book while creating Opportunity in Salesforce for specific record type?

How to prevent users to select Price Book while creating Opportunity in Salesforce for specific record type?

To disable “Price Book” book selection while creating an Opportunity, the Pricebook2Id field should be populated. If the Pricebook2Id field is blank, it will prompt to select the Price Book. So, use some process like Flow or trigger to set the Pricebook2Id field value.
Salesforce Lightning:
 

Salesforce Classic:

 

Sample Trigger:
trigger OpportunityTrigger on Opportunity ( before insert ) {

    for ( Opportunity opp : trigger.new ) {
        
        if ( opp.RecordTypeId == ‘0125f000000q9PLAAY’ ) {
        
            opp.Pricebook2Id = ’01s5f000006jSXoAAM’;
        
        }
    
    }

}

Note:
I have hard coded the RecordTypeId and Pricebook2Id for refernce. Please do not hard code it while implementing.

Leave a Reply