RSS

Visual Flow Choices and Using “Show Input on Selection”

18 Sep
Visual Flow Choices and Using “Show Input on Selection”

Visual Flow “Choices” have a cute little “Show Input on Selection” option where if you click the checkbox, when the user selects that choice a little text field will appear for them to input some text. The question is, how do you gain access to the information that is entered into this box to output to the screen?

What The User Sees

What The User Sees

When you setup a choice you have the option of adding a stored value. In this example I have a constant, named “AddLocationC”, as the stored value.

Add Location Choice

Add Location Choice with “Input on Selection” checkbox selected

The “Show Input on Selection” box is checked so when the user clicks on this choice a little pop-up text box appears with the words “Enter a New Location” to its left.

What happens behind the scenes is the stuff the user types into the text box now becomes the stored value of the choice.

What’s interesting, though, is that if you try to output to the screen the value that was entered, you’ll get the default stored value and not the stuff that was entered into the little box.

So how in the world do you output the text string that was entered into that little pop-up field to the screen? If you output the Screen Choice Field value you get the Choice default stored value (not the input text). And if you output the Choice, you get the same thing (yes, logical, I know, but nevertheless, you never know!).

I found the answer in a round about way as it doesn’t seem to be readily available in any of the SF-sponsored literature.

It seems that the text is sort of buried under the default stored value, and if you assign the choice to a variable, Wha La! it becomes available. I call it Choice-Laundering!

Here is a possible usage case for this nifty little field.

I want the user to be able to fill out a Location field in one of three ways:

  1. Indicating there is not a location
  2. Selecting from a list of locations
  3. Entering a new location
Choice Example

Choice Example

The “NoLocation” choice is a simple Choice that returns an empty string:

No Location Choice

No Location Choice

The “Location” choice is a Dynamic Choice that looks to a custom object where I have various location values stored. In my case I’ve assigned the value of the Dynamic Choice to a variable called “Location”:

Location Dynamic Choice

Location Dynamic Choice

And here is the “AddLocation” choice that shows the “Show Input on Selection” checkbox marked and the Label value that will show up to the left of the pop-up text field:

Add Location Choice

Add Location Choice with “Input on Selection” checkbox selected

When the user selects the “Add Location” choice they get a little pop-up text box where they can enter text:

What The User Sees

What the user sees when they click on a choice that has the “Show Input on Selection” checkbox selected

Finally, here is how I gained access to the value typed into the pop-up text field (in this case “Timbuktu”) to show to the user. I’ve made the default value of a variable the AddLocation choice value:

Location Variable

Location Variable with Default value of Location Choice

Here is a display of the screen choice field value, the choice value itself, and the value of the Location variable. You can see that the screen field and choice are returning the value of the AddLocation choice (which I’ve given a value of “Add Location”). The variable, however, is the value that was typed into the little pop-up field.

Various Location Outputs

Various Location Outputs

In my example I just made the default value of my variable the value of the AddLocation choice field, but of course you could also use an Assign element and assign the choice to a variable.

Now I must reiterate a little caveat. This is important, and it tripped me up for awhile.

The value of the choice is whatever the user typed, not the default stored value.

That’s worth saying again, but I’ll refrain. What that means, though, is when you want to save the user’s input to the database, just go ahead and save your screen choice field to your database without the extra assignment. You’ll only need to use the assignment if you want to show the user what they typed in!

Cheers!

Advertisements
 
1 Comment

Posted by on September 18, 2015 in Visual Flow

 

Tags: , ,

One response to “Visual Flow Choices and Using “Show Input on Selection”

  1. Leandro Valdes Viera (@iamleandrow)

    April 12, 2017 at 3:48 pm

    You gotta love Salesforce! Thanks for this!!

    Liked by 1 person

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: