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
Jeff QuirinJeff Quirin 

Validation Rule on Lookup, Picklist, and Text Field

Trying to write a Validation Rule for a Custom Field on a Custom Object to handle this scenario --- If a Lookup Field is not populated, then a Picklist field and a Text field are required to be populated --- but not prevent this scenario --- If the Lookup Field is populated, then the Picklist may be updated (but is not required), and the Text Field should not be populated.

Tried coming at it a couple different angels and can't get it right. Any thoughts?
Best Answer chosen by Jeff Quirin
badibadi
Try this,

OR( 
 AND( ISBLANK(lookup__c), ISBLANK( TEXT( vrPicklist__c ) ),  ISBLANK( vrText__c )
    ),
 AND( NOT(ISBLANK(lookup__c)) ,NOT(ISBLANK( vrText__c )) ) 
)

Hope this helps

All Answers

GauravGargGauravGarg
Hi Jeff,

Please try with below formula:
OR(
AND(
isBlank(lookup__c),
ISBLANK(TextField),
ISBLANK(picklist)
),
AND(NOT(isBlank(Lookup))),
NOT(ISBLANK(textField))
)

Please try above formula in validation rule, and let me know if need more help on this.

Thanks,
Gaurav
Skype: gaurav62990
Jeff QuirinJeff Quirin
Here is the error I received for that rule:  Error: Field PicklistField__c is a picklist field. Picklist fields are only supported in certain functions. 
badibadi
Try this,

OR( 
 AND( ISBLANK(lookup__c), ISBLANK( TEXT( vrPicklist__c ) ),  ISBLANK( vrText__c )
    ),
 AND( NOT(ISBLANK(lookup__c)) ,NOT(ISBLANK( vrText__c )) ) 
)

Hope this helps
This was selected as the best answer
GauravGargGauravGarg
Jeff,

Try this updated formula:

OR(
AND(
isBlank(lookup__c),
ISBLANK(TextField),
ISBLANK(TEXT(picklist)))
),
AND(NOT(isBlank(Lookup))),
NOT(ISBLANK(textField))
)

Thanks,
Gaurav
Jeff QuirinJeff Quirin
Thank you both! Tested and working with Badi's.