You need to sign in to do that
Don't have an account?
Validation rule : The address should be completely filled or completely blank
Hello everybody,
I could write validation rule to prevent half entry of address...But it is not accepting when it is completely blank.
The validation rule I have written is
OR(
OR(
Billing_Street__c<>null,
ISBLANK( Billing_City__c ),
ISBLANK( Billing_State__c ),
ISBLANK( Billing_Country__c ),
ISBLANK(Billing_Zip_Code__c )),
OR(
Billing_City__c<>null,
ISBLANK( Billing_Street__c ),
ISBLANK( Billing_State__c ),
ISBLANK( Billing_Country__c ),
ISBLANK(Billing_Zip_Code__c )),
OR(
Billing_State__c<>null,
ISBLANK( Billing_City__c ),
ISBLANK( Billing_Street__c ),
ISBLANK( Billing_Country__c ),
ISBLANK(Billing_Zip_Code__c )),
OR(
Billing_Country__c<>null,
ISBLANK( Billing_City__c ),
ISBLANK( Billing_State__c ),
ISBLANK( Billing_Street__c ),
ISBLANK(Billing_Zip_Code__c )),
OR(
Billing_Zip_Code__c<>null,
ISBLANK( Billing_City__c ),
ISBLANK( Billing_State__c ),
ISBLANK( Billing_Country__c ),
ISBLANK(Billing_Street__c )))
Can you please tell me what is the mistake?? By the way I am new to sfdc.
Thanks.
I'm still not 100% sure what you're asking, but see if this gives the results you want:
AND ( OR ( ISBLANK( Billing_Street_c ),
ISBLANK( Billing_City_c ),
ISBLANK( Billing_State_c ),
ISBLANK( Billing_Country_c ),
ISBLANK( Billing_Zip_Code_c ) ),
NOT( AND ( ISBLANK( Billing_Street_c ),
ISBLANK( Billing_City_c ),
ISBLANK( Billing_State_c ),
ISBLANK( Billing_Country_c ),
ISBLANK( Billing_Zip_Code_c ) ) ) )
This one should return true if some of the fields are blank, but not if they are all filled or all blank.
All Answers
Hmmm, I didn't walk all the way through this but I think you are making it too complex. Here is an example I have from the standard account object that does the same thing. If you try it you'll need to change the field names to those of your custom fields
OR(
ISBLANK( BillingStreet) ,
ISBLANK(BillingCity) ,
ISBLANK(BillingState),
ISBLANK(BillingPostalCode),
ISBLANK(BillingCountry)
)
First, to make a null comparison it is better to use ISBLANK() and not the <>null or != null operator (in this case you would need to wrap the ISBLANK() statement with the NOT() function).
Second, the way the OR() works is that if ANY of the conditions is true, it will return true. So you have a lot of extra code in your rule that you don't need. Try simplifying:
OR( ISBLANK( Billing_Street_c ),
ISBLANK( Billing_City_c ),
ISBLANK( Billing_State_c ),
ISBLANK( Billing_Country_c ),
ISBLANK( Billing_Zip_Code_c ) )
If any one of these fields is blank (or all of them), the formula will return true. If they are all filled (which sounds like what you want), the formula will return false.
Thanks for the quick reply....
I am sorry, but it is not allowing me to leave the entire billing address blank
Maybe I misunderstood the question... do you want to be able to leave the entire thing blank?
It is not letting me to leave the shipping fields blank even with this
I'm still not 100% sure what you're asking, but see if this gives the results you want:
AND ( OR ( ISBLANK( Billing_Street_c ),
ISBLANK( Billing_City_c ),
ISBLANK( Billing_State_c ),
ISBLANK( Billing_Country_c ),
ISBLANK( Billing_Zip_Code_c ) ),
NOT( AND ( ISBLANK( Billing_Street_c ),
ISBLANK( Billing_City_c ),
ISBLANK( Billing_State_c ),
ISBLANK( Billing_Country_c ),
ISBLANK( Billing_Zip_Code_c ) ) ) )
This one should return true if some of the fields are blank, but not if they are all filled or all blank.
Thank you very much..This is what I needed...:)