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
Tommy Sunderland 16Tommy Sunderland 16 

Validation Rule based on Opportunity Stage not firing

Having an issue getting a very lengthy Validation Rule to run. Please see the following. The short of the long is to only allow Stage to be "Closing - Confirmed" if:
- Order Process Type is Month to Month 
- # of Activities > 0 
- Product selected 
- App associated to Account 
- App has CC info 
- Proper Pricing Model selected 
- Proper Type selected
-------------------------------------

AND( 

ISCHANGED( StageName ), 
ISPICKVAL(StageName, 'Closing - Confirmed'), 
ISPICKVAL(Order_Process_Type__c, 'Month to Month'), 
Number_of_Activities__c > 0, 

AND( 
Purchase_Educate__c = false, 
OR( 
ISPICKVAL(Purchase_Engage__c, 'No'), 
ISBLANK(TEXT(Purchase_Engage__c)) 
), 
OR( 
ISPICKVAL(Purchase_Resolve__c, 'No'), 
ISBLANK(TEXT(Purchase_Resolve__c)) 

), 
OR( 
Account.Apps_With_Credit_Card__c=0, 
ISNULL(Account.Apps_With_Credit_Card__c) 
), 
OR( 
Account.Total_Number_of_Apps__c=0, 
ISNULL(Account.Total_Number_of_Apps__c) 
), 
Account.Number_of_Active_Apps__c > 0, 
OR( 
AND( 
RecordTypeId = "0121N0000012cms", 
ISPICKVAL(Pricing_Model__c, 'Month to Month (No Base High)'), 
OR ( 
ISPICKVAL(Type, 'New Business - Inbound'), 
ISPICKVAL(Type, 'New Business - Outbound') 

), 
AND( 
RecordTypeId = "0121N0000012cmn", 
ISPICKVAL(Pricing_Model__c, 'Per Product Pricing with Seats'), 
OR ( 
ISPICKVAL(Type, 'New Business - Inbound'), 
ISPICKVAL(Type, 'New Business - Outbound') 



)
jigarshahjigarshah
Tommy,

I believe you are hitting the 5000 formula compile size character limit and are looking for ways to optimize this? Here are sme things you can do.
  • Instead of checking Purchase_Educate__c = false you can simply check NOT(Purchase_Educate__c)
  • Have some intermediate condition groupings broken down into intermitent fields whose conditional results can be computed via a Workflow. For e.g. you could create a checkbox field called IsPurchaseResolved__c and have it evaluate it to true or false based on the same condition which is populated via a Workflow Rule's Field Update action. You can then use the IsPurchaseResolved__c field within your Validation Rule which will significantly reduce the formula character size.
  • Instead of hardcoding the Record Type Id value use the RecordType.Id merge field or use a Custom Label to hold the Record Type Id value and then refer the label in the validatio rule. This technique will provide the flexibility to update the respective Reocrd Type Ids without having to update the Validation Rule, when the envrionments change from Sandbox to Productions where the same Id may not exist.