10

I have a Picklist screen component in a Flow which has many choices defined in the same flow:

Screen component

Now I need to make a formula that references the Choice Value of a given choice:

Choice

If I use UPPER({!Plan} + '_PRODUCT_A') I get (OLD) STARTER_PRODUCT_A instead of STARTER_PRODUCT_A as I expected. I therefore seem to be getting the choice label when I use the {!Plan} placeholder instead of the choice value.

On the suggestion of the comment from User6670 below, I have tried the following:

UPPER(TEXT({!Plan}) + '_PRODUCT_A')

But this yields the following error when I save the flow:

The formula expression is invalid: Incorrect parameter type for function 'TEXT()'. Expected Number, Date, DateTime, Picklist, received Text

How do I write a formula so that I get STARTER_PRODUCT_A as the result?

6
  • so in general formulas we use TEXT(fieldname) function to get value did you use that?
    – User6670
    Commented Feb 5, 2020 at 7:31
  • This seems to be related to Knowledge Article Number 000327830 - Edit your "Choices" and enter a value in the Stored Value section. Simply type the text of the value you'd like the choice to store and pass to Salesforce. Type the literal string with no quotes brackets, etc. (in many situations the stored value will be the same as the label). Disregard the "No Matches Found" message and save the stored value. Your Screen Choice fields mapped to Salesforce (Formula Field) will now pass the choice value selected in the flow screen.
    – Mitesh
    Commented Feb 7, 2020 at 11:47
  • If not then refer the value by assigning the Choice Value to a variable and then referencing this variable in your Screen element or Formula which ever way it works.
    – Mitesh
    Commented Feb 7, 2020 at 11:53
  • @Mitesh How do I do that? Where is this "Stored Value" section? When I create a new "Screen" interaction element on the Flow Builder and add a picklist to it, my options are: API Name, Data Type, Default Value, Choices. If i create a new choice on the Flow Builder, my options are: Resource Type, API Name, Choice Label, Data Type, and Choice Value. See my screenshots above. Is there some option I'm missing here? In case it wasn't clear, my choices don't exist outside of the flow. Commented Feb 7, 2020 at 12:38
  • This must be an edition difference but my point is that if you refer this Choice Value as variable then perhaps it should take that and show in appropriate screen element. You might want to go over the link see if the approach is applicable in your use case. explorationsintosalesforce.wordpress.com/2015/09/18/…
    – Mitesh
    Commented Feb 7, 2020 at 13:09

1 Answer 1

12
+50

For whatever reason, as noted here, you seem to get the label if you refer to the field, but you get the value if you pass the field into a record element/variable.

As @Mitesh stated, you should be able to store the Choice Value as a variable and get what you need.

  1. Create the variable. Click on Manager --> New Resource enter image description here
  2. Select Variable for Resource Type. Leave default as blank and select available for input and output
  3. After your screen component, you need to create assignment logic. enter image description here
  4. Now you can refer to the variable you created to display the value of the choice in your formula as UPPER({!Hold_Choice_Value} + '_PRODUCT_A')

enter image description here

3
  • 3
    Thank you. Why on Earth is this so complicated? Why can't they simply provide "Plan.Label" and "Plan.Value"? 😢 Commented Feb 10, 2020 at 1:00
  • 1
    Unfortunately you cannot use this in single screen, when you want to leverage Component Reactivity. Is there any way around this without the use of assignment element?
    – Damecek
    Commented Sep 5, 2023 at 16:01
  • Actually it worked for me.. I didn’t have to use assignment too. I shared my answer here salesforce.stackexchange.com/a/417568/58767 Commented Feb 21 at 21:30

You must log in to answer this question.

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