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
Danny McGuffinDanny McGuffin 

Validation Rule on Picklist Values check to see if number field is null

Have a picklist with 10 values, when it is picklist option 2 or 3, i want to check to see if a number field is not null.

NOT ( OR ( ISPICKVAL ( FieldName__c , "Option 2" ), ( ISPICKVAL ( FieldName__c , "Option 3" ) ) ) && NOT ( ISNULL ( NumberField__c ) = true ) )

It validates, but no matter what option 2 or 3 I pick, i can also put numbers in the number field and nothing seems to be stopping me from doing anything....
Best Answer chosen by Danny McGuffin
Abdul KhatriAbdul Khatri
just remove NOT then
 
AND (
	OR ( 
		ISPICKVAL ( FieldName__c , "Option 2" ), 
		ISPICKVAL ( FieldName__c , "Option 3" ) 
	),
	ISBLANK (  NumberField__c ) 
)

 

All Answers

Abdul KhatriAbdul Khatri
Please try below
 
AND (
	OR ( 
		ISPICKVAL ( FieldName__c , "Option 2" ), 
		ISPICKVAL ( FieldName__c , "Option 3" ) 
	),
	NOT ( ISBLANK (  NumberField__c ) )
)
Danny McGuffinDanny McGuffin
I am still able to save the record and nothing is firing off. In essence if I pick value 2 or value 3, there MUST be something in the number field. I have tested it both ways, where I have saved the record to option 2 selected and an empty number field, then inputted something into the number field and the picklist option 2 was selected. Nothing was giving me an error.
Abdul KhatriAbdul Khatri
Can you check if your Validation Rule is active. I just mimic and it worked for me

User-added image
Danny McGuffinDanny McGuffin
ok, i see what is happening. Maybe I mistyped what I meant (it happens). if option 2 or 3 is selected, the number field must have something in it. it is sparking an error when a value is in the field.
Abdul KhatriAbdul Khatri
just remove NOT then
 
AND (
	OR ( 
		ISPICKVAL ( FieldName__c , "Option 2" ), 
		ISPICKVAL ( FieldName__c , "Option 3" ) 
	),
	ISBLANK (  NumberField__c ) 
)

 
This was selected as the best answer