Activity Forums Salesforce® Discussions How to get picklist value in Salesforce formula?

  • Avnish Yadav

    Member
    August 7, 2018 at 6:40 am

    Hi Anjali,

    A picklist value often determines which other fields on a record are required. ISPICKVAL() and CASE() are used for creating validation rules that check whether a certain picklist value is selected. For example, say you want users to enter a reason when they change a case’s Status picklist value to Escalated.

    First, create a custom text field Reason for Escalating on the Case object.

    1. Setup, use the quick find box to find the Object Manager.
    2. Click Case | Fields & Relationships and click New.
    3. Select the Text Area and click Next.
    4. In Field Label, enter Reason for Escalating. Field Name populates automatically.
    5. Click Next.
    6. Click Next again and then click Save.

    Now use the Status picklist field to set up a validation rule on Reason for Escalating.
    a. Click the newly created Reason for Escalating field.
    b. Under Validation Rules, click New.
    c. In Rule Name, enter Reason_Required.
    d. In Error Condition Formula, enter the following validation rule:

    AND(
    ISPICKVAL(Status, "Escalated"),
    ISBLANK(Reason_for_Escalating__c)
    )

    e. In Error Message, enter Please enter a reason for changing the case status to Escalated.
    Click Save.

     

    Thanks.

  • William

    Member
    October 30, 2018 at 4:59 am

    A picklist field lets you choose a value from a pre-populated list. While you can’t write a formula that returns a picklist as a result, you likely have to reference picklists in your formula fields.

    Three functions take picklist values as arguments in all formula fields: ISPICKVAL(), CASE(), and TEXT().ISPICKVAL() and CASE() are useful for creating validation rules that check whether a certain picklist value is selected. For example, say you want users to enter a reason when they change a case’s Status picklist value to Escalated.

    Example

    This formula uses the custom date field Payment Due Date and the custom picklist field Payment Status with the options Paid and Unpaid on the opportunity object. If Payment Status is Unpaid and it’s past the payment due date, the formula field displays Payment overdue! Otherwise, the field is blank.

    IF(AND(Payment_Due_Date__c < TODAY(),

    ISPICKVAL(Payment_Status__c, "UNPAID")),  "Payment overdue!", null)

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos