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
SabrentSabrent 

PRIORVALUE ISPICKVAL CONTAINS

I have a custom picklist field Status__c with 6 values ActiveA, ActiveB,ActiveC,ClosedP,ClosedQ,ClosedR


I am trying to write a Workflow rule such that when Status__c is changed from any of the Active values to the Closed values, populate the Closed_Date__c field with date today().


This is my workflow rule but it is giving syntax error
Error: Field Status__c is a picklist field. Picklist fields are only supported in certain functions.

AND(
ISCHANGED(Status__c), ISPICKVAL( PRIORVALUE(CONTAINS(Status__c,"Active"))), ISPICKVAL(CONTAINS(Status__c,"Closed"))
)
Best Answer chosen by Sabrent
AgiAgi
Hi,

in the workflow rule you can use this:

AND(
CONTAINS(TEXT(PRIORVALUE(Status__c )),"Active"),
CONTAINS(TEXT(Status__c ),"Closed"))


regards,
Agi

All Answers

sfdc_ninjasfdc_ninja
Unfortunately, you cannot use CONTAINS with ISPICKVAL.  You need to specify specific status__c values.  With 3 open and 3 closed statuses, there are a decetn amount of combinations so listing them all in a formula might be tedious.  What I would suggest is creating 2 formula fields on your object.  They would be isActive and isClosed.  The formulas would be checkboxes and would be something like

OR(
     ISPICKVAL(Status, 'ActiveA'),
     ISPICKVAL(Status, 'ActiveB'),
     ISPICKVAL(Status, 'ActiveC')
)

You would do the same for the isClosed field.  Now you have a field on the object that tells you if it is active or closed, your formula for your workflow rule becomes much simpler.  Something like below would work

AND(
     ISCHANGED(Status__c),
     isActive__c = false,
     PRIORVALUE(isActive__c) = true,
     isClosed__c = true
)
AgiAgi
Hi,

in the workflow rule you can use this:

AND(
CONTAINS(TEXT(PRIORVALUE(Status__c )),"Active"),
CONTAINS(TEXT(Status__c ),"Closed"))


regards,
Agi
This was selected as the best answer
SabrentSabrent
thanks sfdc _ninja and Agi.