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 : ) {
        if ( opp.RecordTypeId == '0125f000000q9PLAAY' ) {
            opp.Pricebook2Id = '01s5f000006jSXoAAM';


I have hard coded the RecordTypeId and Pricebook2Id. Please do not do it while implementing.

No comments:

Post a Comment