0

I have few scenarios

  1. When ever stage picklist - Support selected and saved, it should not save if any of the fields address,state,city are blank
  2. There is a check box, if it is enable to true then also it should check if any of the fields (address, city state,zip,quantity) is blank , it should not allowed to save

Can Someone help me with this? I tried below validation, but it is not working.

IF( 
    AND(
        ISPICKVAL(Status__c,"Support"), 
        ISBLANK(Address__c),
        ISBLANK(City__c),
        ISPICKVAL(State__c," ")
    ), True,False
)
1
  • 1
    Just a note, you can always replace IF(condition, true, false) with condition.
    – Adrian Larson
    Commented Apr 25, 2016 at 23:34

1 Answer 1

1

AND means that all the criteria has to be met. Personally, I'd use one validation rule per field:

AND( ISPICKVAL(Status__c,"Support"),  ISBLANK(Address__c))

AND( ISPICKVAL(Status__c,"Support"),  ISBLANK(City__c))

AND( ISPICKVAL(Status__c,"Support"),  ISPICKVAL(State__c,""))

The reason why is so that the correct field(s) will be highlighted for the user, so they can fix their mistakes.

As a single rule, however, you need to combine AND and OR to get the desired results:

AND( ISPICKVAL(Status__c,"Support"),
    OR(ISBLANK(Address__c), ISBLANK(City__c), ISPICKVAL(State__c,"")))

This will cause the validation to trigger when any of the three fields are empty when Status is "Support."

If you'd like the checkbox or the Status picklist value to show the same error, you can combine the validation to a single formula:

AND( OR(MyCheckbox__c, ISPICKVAL(Status__c,"Support")),  ISBLANK(Address__c))

Otherwise, if you want to show distinct errors, you'd just write additional validation rules:

AND( ISPICKVAL(Status__c,"Support"),  ISBLANK(Address__c))

AND( MyCheckbox__c,  ISBLANK(Address__c))

You can do the same thing for the other fields, as well.

5
  • For check box scenario, validation rule not working properly AND( OR( Verification__c = TRUE), ISBLANK(Ship_Date__c), ISBLANK(TotalQuantity), ISBLANK(Address__c), ISBLANK(City__c), ISPICKVAL(State__c,""), ISBLANK(Zip_Code__c))
    – sai
    Commented Apr 26, 2016 at 4:48
  • AND( ISPICKVAL(Status__c,"Support"), ISBLANK(Address__c)) AND( ISPICKVAL(Status__c,"Support"), ISBLANK(City__c)) AND( ISPICKVAL(Status__c,"Support"), ISPICKVAL(State__c,"")) - Just wanted to know for the above validation, do i need to write seperate validation rule for each of them ??
    – sai
    Commented Apr 26, 2016 at 16:13
  • @sai I strongly recommend using multiple rules. This makes it easier for a user to determine which field(s) are required, because they will be highlighted.
    – sfdcfox
    Commented Apr 26, 2016 at 16:15
  • Yes I am doing that, Can you help me with an add on condition for checkbox, condition should work only when checkbox is enabled from disable, if MyCheckbox__c = false and when MyCheckbox__c = true, validation should work. I mean to say it should not effect old opportunities, I know there is PRIOR , I can check old values right? can you help in the logic please
    – sai
    Commented Apr 26, 2016 at 17:45
  • AND( AND(Validate__c, NOT PRIORVALUE(Validate__c), ISBLANK(State__c) ) is an example of how you can check that transition.
    – sfdcfox
    Commented Apr 26, 2016 at 17:59

You must log in to answer this question.

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