0

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”
)
4
  • doesn't look like the syntax error was added to the question? You can edit and add the error you're getting. Likewise, as Status is a picklist you'll want to look at the Use Picklists in Formulas trailhead which shows how to combine this with PRIORVALUE() Commented Jan 7, 2022 at 14:47
  • Hi Rangelli, There is no Syntax error in the formula except the double quotations. Change TEXT(Status)=”Activated” to TEXT(Status)="Activated". And make sure that workflow criteria is set as "created, and every time it’s edited " Commented Jan 7, 2022 at 15:04
  • 1
    Welcome to Salesforce Stack Exchange (SFSE)! Another possibility is the use of "Smart quotes" rather that "straight quotes." "Smart quotes" are most likely introduced when copying/pasting from a Microsoft Office application or from a blog post not formatting their code snippets in the best way. [EDIT: This is an expansion/explanation of what SaiPraveen Kakkirala posted in the comment above this one.]
    – Moonpie
    Commented Jan 7, 2022 at 15:15
  • Thank you for the welcome and the answer! @Moonpie It was the " issue.. I was using a word doc to write the code. :| Do you have any code editors you can suggest?
    – Rangell
    Commented Jan 7, 2022 at 16:11

1 Answer 1

3

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.
2
  • Thank you so much!! It was the " issue. I appreciate all the help here.. StackExchange has helped me more times than I can count!
    – Rangell
    Commented Jan 7, 2022 at 16:11
  • @Rangell fyi - it's valuable to upvote & accept answers that are helpful - see What should I do when someone answers my question? Commented Jan 7, 2022 at 18:59

You must log in to answer this question.

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