0

I have a requirement to display an error message when user selects 10 types of cars from the available picklists.

Here, I have created a formula field to display alert message. and implemented a formula as below.

Here, I am facing an error 'Compiled formula is too big to execute'. Please suggest me a way to minimize my formula that could be greatful.

IF(
AND(ISPICKVAL(Make_manual__c, 'Honda'),ISPICKVAL(Model_manual__c, 'Accord'),ISPICKVAL(Year_manual__c, '2001')) ||
AND(ISPICKVAL(Make_manual__c, 'Honda'),ISPICKVAL(Model_manual__c, 'Accord'),ISPICKVAL(Year_manual__c, '2002')) ||
AND(ISPICKVAL(Make_manual__c, 'Honda'),ISPICKVAL(Model_manual__c, 'Civic'),ISPICKVAL(Year_manual__c, '2001')) ||
AND(ISPICKVAL(Make_manual__c, 'Honda'),ISPICKVAL(Model_manual__c, 'Civic'),ISPICKVAL(Year_manual__c, '2002')) ||
AND(ISPICKVAL(Make_manual__c, 'Honda'),ISPICKVAL(Model_manual__c, 'Pilot'),ISPICKVAL(Year_manual__c, '2003')) ||
AND(ISPICKVAL(Make_manual__c, 'Honda'),ISPICKVAL(Model_manual__c, 'CR-V'),ISPICKVAL(Year_manual__c, '2002')) ||
AND(ISPICKVAL(Make_manual__c, 'Honda'),ISPICKVAL(Model_manual__c, 'Odessey'),ISPICKVAL(Year_manual__c, '2002')) ||
AND(ISPICKVAL(Make_manual__c, 'Accura'),ISPICKVAL(Model_manual__c, '3.2TL'),ISPICKVAL(Year_manual__c, '2002')) ||
AND(ISPICKVAL(Make_manual__c, 'Accura'),ISPICKVAL(Model_manual__c, '3.2TL'),ISPICKVAL(Year_manual__c, '2003')) ||
AND(ISPICKVAL(Make_manual__c, 'Accura'),ISPICKVAL(Model_manual__c, '3.2CL'),ISPICKVAL(Year_manual__c, '2001'))
)True,false)
4
  • Here there are 3 fields for each car Model, Make, Year for each one. So here i have added 10 AND conditions with OR combination for each
    – venky
    Commented Jul 3, 2016 at 18:04
  • remove your IF statement, result already will be boolean Commented Jul 3, 2016 at 18:58
  • 1
    Assuming you need this to scale, in would look at vlookup validation rules. You would need a custom object to validate against. I've done this using fields on the custom object (for make,model,and year) and setting the name of the custom object using a workflow rule. Then you can create a formulal field on the object w the val rule, and evaluate this field against the name field on the custom object. This can scale indefinitely.
    – gorav
    Commented Jul 3, 2016 at 22:33
  • you can use CASE statement for efficiency and to reduce length. Commented Jul 4, 2016 at 1:57

1 Answer 1

0

You can unite fields by they frequency:

AND(ISPICKVAL(Make_manual__c,'Honda'),
AND(ISPICKVAL(Year_manual__c,'2001'),CONTAINS("Accord:Civic",text(Model_manual__c)))||
AND(ISPICKVAL(Year_manual__c,'2002'),CONTAINS("Accord:Civic:CR-V:Odessey",text(Model_manual__c)))||
AND(ISPICKVAL(Year_manual__c,'2003'),CONTAINS("Pilot",text(Model_manual__c))))||
AND(ISPICKVAL(Make_manual__c,'Accura'),
AND(ISPICKVAL(Model_manual__c,'3.2TL'),CONTAINS("2002:2003",text(Year_manual__c)))||
AND(ISPICKVAL(Model_manual__c,'3.2CL'),CONTAINS("2001",text(Year_manual__c))))
1
  • Great thanks!!The above logic works good. Here, i need to add some more conditions. When i have added other conditions, still facing this error (too big to execute). Is there a way to achieve this or any other way to get the requirement done.
    – venky
    Commented Jul 4, 2016 at 10:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .