0

trying to build a formula field to define FCR and my formula always turns wrong. The first part works correctly however I'm receiving an

error : Field Reason_for_Reopen__c is a picklist field. Picklist fields are only supported in certain functions.

IF(
    AND(
        IsClosed = TRUE ,
        First_Response_Time__c != NULL
    ), 
    'FCR Met',
    IF(
        AND(
            ISPICKVAL(Reason_for_Reopen__c != 'AUTO REPLY EML'),
            First_Response_Time__c != NULL
        ),
        'FCR Met',
        'FCR Not Met'
    )
)

Is there any changes I need to make on my formula or is the use of ISPICKVAL is wrong?

1 Answer 1

1

You're not using ISPICKVAL() correctly.

Taking a look at the documentation for ISPICKVAL(), you'll see that it takes 2 parameters: the picklist field, and the value you want to check.

Note that you can only check if a picklist is currently a certain value. There is no ISNOTPICKVAL() function. To do what you want to do, you need to first use ISPICKVAL() to say that Reason_for_Reopen__c is AUTO REPLY EML. Then you can wrap that in a NOT() to get the "reopen reason is not auto reply email" that you want.

IF(
    AND(
        IsClosed = TRUE ,
        First_Response_Time__c != NULL
    ), 
    'FCR Met',
    IF(
        AND(
            /* You need to get rid of the "!=" and use a comma so that */
            /*   you're passing the correct number (and type) of parameters */
            /* Then, wrap it in a NOT() so that you end up with the behavior of != */
            NOT(ISPICKVAL(Reason_for_Reopen__c, 'AUTO REPLY EML')),
            First_Response_Time__c != NULL
        ),
        'FCR Met',
        'FCR Not Met'
    )
)

Alternatively, TEXT(Reason_for_Reopen__c) != 'AUTO REPLY EML would also work

You can also merge the conditions for the first and second IF() to remove the second one1.

IF(
    /* Knowing when to use AND() and when to use OR() takes a bit of experience */
    /* Using AND() is appropriate here */
    AND(
        /* This is common to both checks, so we can factor this out */
        First_Response_Time__c != NULL,
        OR(
            IsClosed = TRUE,
            NOT(ISPICKVAL(Reason_for_Reopen__c, 'AUTO REPLY EML')),
        )
    ),
    'FCR Met',
    'FCR Not Met'
)

1: What you have is effectively (X && Y) || (X && Z). Using the property of distributivity of AND and OR, you can pull out the common part, the X. So the expression becomes X && (Y || Z), which using AND() and OR() functions becomes AND(X, OR(Y, Z))

You must log in to answer this question.

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