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
sp13sp13 

validation rule field should be null

i have a checkbox field Checkbox1__c and two text fields TextField1__c and TextField2__c
this validation rule doesn't work: IF( Checkbox1__c== false, TextField1__c= null && TextField2__c= null, TextField1__c= null && TextField2__c= null)

i want to create a validation rule that when Checkbox1__c is unchecked, the TextField1__c and TextField2__c should have no values. help ?
Best Answer chosen by sp13
Marty C.Marty C.

Hello, sp13, try this:

AND( Checkbox1__c == FALSE ,
NOT( AND( ISBLANK( TextField1__c ) , ISBLANK( TextField2__c ) ) ) )

All Answers

Phillip SouthernPhillip Southern
Hi sp13,

You could do this with a different set of functions, like this:

AND(Checkbox1__c=false, OR(NOT(ISNULL(textfield1__c)), NOT(ISNULL(textfield2__c)))

The If statement you had was only comparing the checkbox field (first comarisons before the first comma.  If statment read like this:
IF(comparison, value set if true, value set if false)

With the above rule I listed we are saying....for the condition: checkbox is false AND (textfield 1 is not null OR textfield 2 is not null)
Marty C.Marty C.

Hello, sp13, try this:

AND( Checkbox1__c == FALSE ,
NOT( AND( ISBLANK( TextField1__c ) , ISBLANK( TextField2__c ) ) ) )

This was selected as the best answer