Syntax error when using priorvalue in formula

formulapicklist

I am just learning the priorvalue formula.
I want a workflow to trigger when the status of my contract changes from On Hold to Activated.

I created the following and I am getting syntax error:

AND(
ISCHANGED(Status), 
TEXT(PRIORVALUE(Status))="On Hold",
TEXT(Status)=”Activated”
)

Best Answer

It looks like you have some "smart quotes" in there, which will end up throwing some errors. That's unrelated to how to use picklists in formulas though.

In general, when you're working with picklists (such as your standard "Status" field), you need to use ISPICKVAL(). TEXT() can also work, the Use Picklists in Formulas unit on trailhead that Kris points to seems to indicate that both ISPICKVAL(PRIORVALUE(field), value)) and TEXT(PRIORVALUE(field)) = value would work.

The ISCHANGED() is also unnecessary here, since you're looking for a specific prior value. That is to say, if Status was "on hold" and now is "activated", ISCHANGED() would be true. You don't gain anything here by having that check.

So, to sum things up:

  • Get rid of that ISCHANGED(), it's unnecessary
  • ISPICKVAL(PRIORVALUE(<picklist field>), "target value") or TEXT(PRIORVALUE(<picklist field>)) = "target value") should work. Pick one of those two styles, and stick with it. Be consistent throughout your org, and don't mix-and-match
  • Be sure to use single-quotes ' or double-quotes ", and not "smart" quotes. Again, pick one and use it consistently.
Related Topic