+ Start a Discussion
HNT_NeoHNT_Neo 

Opportunity Stage VR

Trying to create this VR on the record types shown in the code. 

The idea is for only these 3 record types to trigger the VR when the picklist "Stage equals Conversion" and if the field "Total_Annual_Sqft_Interior__c" is left blank, it wll not allow the user to save the record, unless there is a value in the "Total_Annual_Sqft_Interior__c" field. 

So, when I log in as a user, the validation rule seems to be triggered by any Opportunity Record type. 

Can someone help me tweak this?

Please note, the  "NOT($Profile.Name ="System Administrator")", is good on this VR, since I want to omit myself from this VR.

Thanks in advance!


RecordTypeId = "012d0000000WK8O" /*Interior Contractor*/ ||
RecordTypeId = "012d0000000We79" /*Interior Dealer/Distributor*/ ||
RecordTypeId = "012d0000000WWPM" /*Interior Quick Convert Opportunity*/
&&
ISPICKVAL(StageName, "Conversion")
&&
ISBLANK(Total_Annual_Sqft_Interior__c)
&&
NOT($Profile.Name ="System Administrator")


Best Answer chosen by HNT_Neo
Subhash GarhwalSubhash Garhwal
Hi JH_Neo,

try this one

AND(
OR( RecordTypeId  = '012d0000000WK8O', RecordTypeId  = '012d0000000We79',RecordTypeId  = '012d0000000WWPM'),
ISPICKVAL(CustomerPriority__c , 'Conversion')
,ISBLANK( Total_Annual_Sqft_Interior__c ),
NOT( $Profile.Name = 'System Administrator')
)

But I think use of Record Type DeveloperName is batter than record type Id because if you use record type Id than you need to update your VR if you move it from sandbox to product.
But if you use Record Type's DeveloperName than you don't need to do this,one more thing Record Type's DeveloperName is also unique.

To get Record Type DeveloperName (Name) follow these steps

Object -> RecordType -> Name (Not Label)


In that case your VR is

AND(
OR( RecordType.DeveloperName  = 'DeveloperName (Name)', RecordType.DeveloperName  = 'DeveloperName (Name)',RecordType.DeveloperName  = 'DeveloperName (Name)'),
ISPICKVAL(CustomerPriority__c , 'Conversion')
,ISBLANK( Total_Annual_Sqft_Interior__c ),
NOT( $Profile.Name = 'System Administrator')
)

Thanks

All Answers

Subhash GarhwalSubhash Garhwal
Hi JH_Neo,

try this one

AND(
OR( RecordTypeId  = '012d0000000WK8O', RecordTypeId  = '012d0000000We79',RecordTypeId  = '012d0000000WWPM'),
ISPICKVAL(CustomerPriority__c , 'Conversion')
,ISBLANK( Total_Annual_Sqft_Interior__c ),
NOT( $Profile.Name = 'System Administrator')
)

But I think use of Record Type DeveloperName is batter than record type Id because if you use record type Id than you need to update your VR if you move it from sandbox to product.
But if you use Record Type's DeveloperName than you don't need to do this,one more thing Record Type's DeveloperName is also unique.

To get Record Type DeveloperName (Name) follow these steps

Object -> RecordType -> Name (Not Label)


In that case your VR is

AND(
OR( RecordType.DeveloperName  = 'DeveloperName (Name)', RecordType.DeveloperName  = 'DeveloperName (Name)',RecordType.DeveloperName  = 'DeveloperName (Name)'),
ISPICKVAL(CustomerPriority__c , 'Conversion')
,ISBLANK( Total_Annual_Sqft_Interior__c ),
NOT( $Profile.Name = 'System Administrator')
)

Thanks
This was selected as the best answer
HNT_NeoHNT_Neo
Thanks Sub!

I used the first solution, I couldn't get the second solution to work for me. 

But just curious, is this how the second one should have looked?

AND(
OR( RecordType.DeveloperName  = 'DeveloperName (Interior_Quick_Convert_Opportunity)', RecordType.DeveloperName  = 'DeveloperName (Interior_Dealer_Distributor)',RecordType.DeveloperName  = 'DeveloperName (
Interior_Contractor)'),
ISPICKVAL(CustomerPriority__c , 'Conversion')
,ISBLANK( Total_Annual_Sqft_Interior__c ),
NOT( $Profile.Name = 'System Administrator')
)



Subhash GarhwalSubhash Garhwal
Try this one

AND(
OR( RecordType.DeveloperName  = 'Interior_Quick_Convert_Opportunity', RecordType.DeveloperName  = 'Interior_Dealer_Distributor',RecordType.DeveloperName  = 'Interior_Contractor'),
ISPICKVAL(CustomerPriority__c , 'Conversion')
,ISBLANK( Total_Annual_Sqft_Interior__c ),
NOT( $Profile.Name = 'System Administrator')
)

Thanks