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
SainSain 

How do i write a Formula using a Picklist?

Hi,

I have two objects called object1, object2(Master) and having lookup relationship among them, In object1 having a field called test1 and in Object2 having fields test2(piclist values are A,B), test3(picklist values x,y).
Now i am creating a validation rule on object1 to make test1 field mandatory while test2 is 'A' and test3 is 'x'

AND(ISPICKVAL(object1__r.test2__c='A'),ISPICKVAL(object2__r.test3__c='x') )

Getting below error:

 Field test2__c is a picklist field. Picklist fields are only supported in certain functions.

and also changed my expression with TEXT but still i am not able to sove it.
AND(TEXT(ISPICKVAL(object1__r.test2__c='A'))


Any suggestions from community.

Thanks in advance.



Best Answer chosen by Sain
JayantJayant
The syntax is - 
ISPICKVAL(object1__r.test2__c, “xyz”)

Note that "xyz" or the String literal should be in double quotes. Both parameters should be separated by a comma and you can't use equals operator.

If this resolves your problem, please mark it as Resolved.

All Answers

JayantJayant
The syntax is - 
ISPICKVAL(object1__r.test2__c, “xyz”)

Note that "xyz" or the String literal should be in double quotes. Both parameters should be separated by a comma and you can't use equals operator.

If this resolves your problem, please mark it as Resolved.
This was selected as the best answer
ManojjenaManojjena
HI Sain ,

Please try with below code it will help ! 
 
AND(ISBLANK(Test1__c),ISPICKVAL(object1__r.test2__c, 'A'),ISPICKVAL(Test3__c , 'X'))

Thnaks
Manoj
SainSain
Thanks for your support jayant, manoj.