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
Sienna Luard 3Sienna Luard 3 

Validation rule to make a picklist field mandatory for Closed Opps that are a certain Record Type

I Validation rule to make a Multi-select picklist field (Competitors) mandatory for Closed Opps that are a certain Record Type (Initial Opportunity.  I am using this formula.

AND
(IsClosed = TRUE, 
( RecordType.DeveloperName ="Initial Opportunity"), 
ISBLANK( 
TEXT( Competitors__c ))
)

I get no syntax errors, but when I close an Opp there is no error msg.

Any ideas>
VinayVinay (Salesforce Developers) 
Hi Sienna,

Can you update below
( RecordType.DeveloperName ="Initial Opportunity"), 

Updated
=======

( RecordType.Name ="Initial Opportunity"),

You need to use API name of record type if you are using 'RecordType.DeveloperName'.  If you are using a label name then use 'RecordType.Name'

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
Sienna Luard 3Sienna Luard 3
Thanks so much for responsing.  

I am made the following update and the validation rule is still not firing.

AND
(IsClosed = TRUE, 
( RecordType.Name = "Initial_Opportunity"), 
ISBLANK( 
TEXT( Competitors__c ))
)

What am I missing?
VinayVinay (Salesforce Developers) 
Hi Sienna,

Try below,  I tested from my end and its working.
AND
(IsClosed = TRUE,
RecordType.Name = 'Initial Opportunity',
ISBLANK(Competitors__c)
)
Thanks,
Vinay Kumar
Sienna Luard 3Sienna Luard 3
Hi Vinay, 

Our Competitors__c field is a multi-select picklist field so I got the message "Error: Field Competitors__c is a picklist field. Picklist fields are only supported in certain functions." 

I added TEXT back and change to single quotes around Initial Opportunity and tried this.

AND
(IsClosed = TRUE, 
( RecordType.Name = 'Initial_Opportunity'), 
ISBLANK( 
TEXT( Competitors__c ))
)

The Validation Rule still does not fire.  
VinayVinay (Salesforce Developers) 
Hi Sienna,

Strange and not sure why it's not working in your case and it's working I have used multi-select picklist.

Can you try to check both scenarios "RecordType.Name = 'Initial_Opportunity' 'and RecordType.Name = 'Initial Opportunity' ".

Run below SOQL query
SELECT id,IsClosed,RecordTypeId FROM Opportunity where IsClosed=true
Pick the opportunity id which has IsClosed=true and record type = 'Initial Opportunity'.

Thanks,
Vinay Kumar
Sienna Luard 3Sienna Luard 3
I got this formula to work.

AND(
ISPICKVAL( StageName ,'Closed Won'),
RecordTypeId = '01270000000Hpxb',
ISNULL(Competitors__c )
)
VinayVinay (Salesforce Developers) 
Good to know you have a working formula.

Review below formula as well and it should work as well as it worked in my org.
AND (IsClosed = TRUE, RecordType.Name = 'Initial Opportunity', ISBLANK(Competitors__c) )
Thanks,
Vinay Kumar