0

I trying to create a validation rule, but I'm getting an error

Error: Incorrect number of parameters for function 'ISPICKVAL()'. Expected 2, received 1

my formula is below. I don't want anyone with the TI:GER User permission set to be able to edit the four Academic Programs.

AND(
    OR (
        $Permission.Scheller_TI_GER_User , 
        OR(
            ISPICKVAL (Academic_Program_name__c = 'Full-time MBA'),
            ISPICKVAL (Academic_Program_name__c = 'Evening MBA'),
            ISPICKVAL (Academic_Program_name__c = 'Executive MBA - GB' ),
            ISPICKVAL (Academic_Program_name__c = 'Executive MBA - MOT')
        ),
        NOT(
            (
                ISPICKVAL (Academic_Program_name__c, TI_GER_Program)
            )
        ),
        RecordType.DeveloperName = 'Academic_Program'
    )
)

1 Answer 1

2

As we can take from the relevant documentation

ISPICKVAL() is not used like

ISPICKVAL(Academic_Program_name__c = 'Full-time MBA')

but rather like

ISPICKVAL(Academic_Program_name__c, 'Full-time MBA')

The first parameter is the picklist field
The second parameter is the value (and only one value at a time) you want to test against
both are required, and they must be separated by a comma

ISPICKVAL (Academic_Program_name__c, TI_GER_Program) is also a problem, because the second parameter needs to be a string. With the context that you've given us, I can't say what TI_GER_Program should be, only that it is not correct.

+edit:
Turns out that Academic_Program_name__c is not a picklist field, in which case using ISPICKVAL() is not appropriate.

Everything other than picklists (and multipicklists) is tested for equality simply by using =

AND(
    OR (
        $Permission.Scheller_TI_GER_User, 
        OR(
            Academic_Program_name__c = 'Full-time MBA',
            Academic_Program_name__c = 'Evening MBA',
            Academic_Program_name__c = 'Executive MBA - GB',
            Academic_Program_name__c = 'Executive MBA - MOT'
        ),
        NOT(
            /* The extra set of parentheses here accomplish nothing */
            /*   so they have been removed */
            /* Parentheses are used with functions and to specify */
            /*   a particular order that you want to do things in */
            /* That second usage only makes sense when they enclose */
            /*   more than just a single statement */
            Academic_Program_name__c = 'TI_GER_Program'
        ),
        RecordType.DeveloperName = 'Academic_Program'
    )
)
5
  • Hi Derek, thanks for you quick reply. When I change to ISPICKVAL (Academic_Program_name__c, TI_GER_Program) I got a new Error: Incorrect parameter type for function 'ISPICKVAL()'. Expected Picklist, received Text Apr 23, 2023 at 22:05
  • @CodellGATech picklists are different from text fields. ISPICKVAL() is used with picklists. For plain 'ol text fields (that is, not textarea, longtextarea, or encrypted text fields), you just do the comparison directly (i.e. MyTextField__c = 'some value')
    – Derek F
    Apr 23, 2023 at 22:38
  • It's a Formula (Text) field, should I use something other than ISPICKVAL()? Apr 23, 2023 at 22:53
  • @CodellGATech Again, ISPICKVAL() is used for picklists and only picklists. Everything else is just a plain, direct comparison.
    – Derek F
    Apr 24, 2023 at 11:15
  • Thanks for you help with this!! I was able to get it working with this formula. AND( OR ($Permission.Scheller_TI_GER_User , OR (Academic_Program_name__c = 'Full-time MBA')) , NOT((Academic_Program_name__c = 'TI:GER Program'))) Apr 24, 2023 at 16:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .