There was a post in the Official: Salesforce Workflow Automation:
One of the field that user inputs on the screen is picklist in Salesforce. What is the best element to use for that. Do I need to create all picklist values as choices or is there any other way? Appreciate your help.
The short answer is, every picklist must be created in each Flow by a Dropdown List and Choices. There is a long answer (very long!), and it’s Custom Settings! Custom Settings were reviewed in Learning Flow 1.B. Find Related Records and Have Users Select Them in a Screen – Select a Contact and Price Book. The Custom Settings reviewed in that post were Hierarchy, the Custom Settings in this post will be List.
Start by going to Setup and search Custom Settings in the Setup Search Bar. Click on Custom Settings. For the Label, type Picklist Fields, and for the Object Name, type Picklist_Fields. Select List for the Setting Type, Visibility can be Public. For description, type, picklist fields for different objects based on Record Type.
Click Save. You should now see this.
You’ll start with the section that says, Custom Fields. Click New. Select the Data Type of Text, then click Next. Name the Field Label Object, length of 255, and the Field Name should be populated as Object as well. Click Next then Save & New. For the next New Custom Field, select the Data Type as Text, then click Next. Enter the Field Label as Field and the length as 255, Field Name should be Field, then click Next. Click Save & New. For the Data Type, select Text Area, type Record Types as the Field Label, the Field Name should show Record_Types. Click Next, then Save. You should see this.
Now click Manage. For this example, you are going to recreate the picklist field of Stage from Opportunity. You should see this page.
Click New. You’ll create the first one with visuals, after that, you’ll be set to continue entering them yourself. Start by typing the Name of the picklist value, since you’re doing the Stage picklist on Opportunity, start with the first picklist value, Prospecting. Then type in the Object field, Opportunity, then Field as (you can pick the API name or the Field Name itself, for this post, you’ll go with API Name) StageName, and enter all 18 digit Record Type Ids of the Record Types that contain Prospecting, separated by commas. In the development environment, there are no record types, so you can leave that blank in this environment.
Continue to create all the picklist field values that make up the Stage field on Opportunity. Your screen, at the end, should look like this.
Uh oh, everything is out of order! If you were to use a dynamic picklist field, you wouldn’t be able to sort by name for this field. So, go back to the main Custom Setting Picklist Fields page. In the Custom Fields section, click New. Then select Number as the Data Type. For the field label, type Order, you can leave the length at 18, then click Next, then Save. You should see Order as another field. Click Manage and then click Edit on each of the Picklist Fields to add an order to the field. Make sure to match the order in the Opportunity Stage Field! You will see an example of the first one below.
Make sure to do that for each field in the list, and then you’re ready to go to Flows!
For this post, since you’ll just need to see how to recreate the picklist field in the Flow, you won’t connect it to anything, so this is informational on how to build the picklist field in Flows using Custom Settings instead of actually connecting or doing anything with the Flow.
Create a New Flow. First, Create a new sObject Variable by clicking on Resource at the top and double clicking on sObject. Type in sovOpportunity for the Unique Name, and the Object Type as Opportunity and click Save. Since you aren’t connecting to anything or truly doing anything other than build a picklist, those variables don’t matter in this example too much, but make sure they are correct when you’re using this in your actual Flows!
Take the Screen from the Palette and drag it to the Canvas. Type the Name as Picklist Test, Don’t show Previous button, and uncheck Show Pause button. Click Add a Field, and drag over the Dropdown List. Click on the [Dropdown List]. For the Label and Unique Name, type Stage. Click the drop down arrow for Choice Select Resource and select Create New Dynamic Choice. For the Unique Name, type OpportunityStage. Value Data Type for this field is Text, so that is ok. This next part is important. For the object, select your custom object, Picklist_Fields__c. Yep, Custom Settings are essentially custom objects, but reside in memory, so they are easier to grab. For the Field, select Object__c, Operator equals, and for Value, type Opportunity. Click Add Row. F: Field__c O: equals V: StageName. If you were using Record Types, you would click Add Row, F: Record_Types__c O: contains V: sovOpportunity.RecordTypeId. This last piece will search the field, Record Types, where you entered all the Record Type 18 digit Ids that were allowed the picklist value. Since there isn’t a Record Type in development orgs set up from the beginning, you’ll skip this one for now if you are using a standard development org. For the Label and Value, select Name. Next, check Sort results by: and in this case, since you want to sort by Order instead of by Name, select Order__c and then Ascending. For the Field and Variable section at the bottom, you might want to assign the Opportunity the new Stage, so you might write Field: Name and Variable: sovOpportunity.StageName. In this case, since you’re not updating anything, you can delete the row by clicking on the trash can on the right hand side of the row. Your Dynamic Choice should look like the below image.
Click OK. You should see this.
Click OK. Set the Picklist Test Screen as the start element by clicking on the green circle with the white down arrow. The Save the Flow and name it Picklist Test. Click OK. Don’t worry about the general warning, you shouldn’t have the Screen connected to anything. Click Run. You should see this.
Congratulations! You just recreated the picklist field for Stage on Opportunity using Custom Settings so that you can easily add it to Flows! Make sure if you change the Stage field on the Opportunity object or any Record Type settings associated with the Stage field on the Opportunity object, you go update the Custom Setting Picklist Fields too!!! (Much better in one place once than many Flows!!!) Now you can use this with any picklist field on any object to help you build better Flows!
Update: Here is a cheat sheet I built for the SoCal User Group and the Salesforce University from 2015.
11 thoughts on “Replicate a Picklist in a Flow”
Great stuff Rich! I use a little different technique. I have a plugin that takes a picklist and writes the values to records on a custom object. You can then do a dynamic choice from the custom object. See this post on the Success Communities. https://success.salesforce.com/0D53000001dwvEk
LikeLiked by 1 person
Thanks for sharing! I’ve been following your blog, I’m sure my readers should too! If you’re reading this and you’re not John, click on his blog link and get great stuff on Flows and other Salesforce things! https://salesforcedude.wordpress.com/
Custom Settings are essentially a Custom Object, but the Custom Object stays in memory, so you can get to it at any time using $(Custom_Setting_Name). So it seems doing a dynamic choice on a custom object (setting in my case, but technically an object) is definitely the way to go! 🙂 Using Custom Settings allows someone to do this all with clicks, not Apex code, and reduces the Flow from needing an additional element, the Apex Plug-in element. I do like in your package using this with a Radio Button dynamic choice instead of a Dropdown List dynamic choice, I’ll have to use that in the future! 🙂
LikeLiked by 1 person
Thanks so much Rich – sensational instructions, I’ve replicated 4 picklists and built them into a flow which presents on a VF screen and I’ve run it all through and it all works!! YAY me!
Awesome, great job Keri-An!
Great blog. I am new to flow and your blog has been very helpful. I am having trouble mapping a picklist value selected in my flow to the picklist value on my Salesforce record. My flow will create a new case record and I am trying to map a case reason (from input screen) to the standard case reason field on the case record. I have read a few posts on the community that states you cannot update picklist fields from a record create flow. If I use your above solution, do you know if the value selected from the flow will map to the correct case field. OR do you have any other recommendations for mapping picklist choices to the standard field on record create?
Thank you so much!
Thank you, I’m glad the blog has been helpful!
I am able to map to the case reason on a record create. I’m not entirely sure why people are saying you can’t map to a picklist field, but you can!
The trick with picklist fields in Flows is that if you need to use the picklist field more than once, you will have multiple Flows that will use that picklist field, or the values of the picklist field change a decent amount, then creating a re-usable picklist is helpful! If you try this way for reusable picklists, it should work for you in your flow. The trick, for either the reusable picklist or creating a picklist in a Flow manually, is that the stored value should be the value that is the picklist value that you want to create/update the record with.
I hope this helps, let me know if it works!
What happens if you have a picklist value that crosses multiple fields? When I try to create it for the second field it errors? Thoughts? “Error: There is already an item in this list with the name Alabama”
What happens when you have a PL value that crosses multiple fields. When I go to create it for the second field I receive an error, even though its a different field that will be using it.
Error: There is already an item in this list with the name Alabama
Great question! Sorry for the late response, I was out during the July 4th holiday.
With Custom Settings, the Name field that Salesforce creates must be unique, so as a result, I would suggest to create a new field, perhaps called Value, for the value of the picklist. Then, you can have multiple entries use the same Value, like we do with Field or Object. If you go down this route, I suggest using a naming convention for the Name field that has meaning. This could be something like, Opp-Stage-CL, for Opportunity – Stage – Closed Lost, or something that is easy to identify. You could number each one, or for each picklist have a number convention, like 001-XX for Opportunity Stage, 002-XX for Lead Status, etc. With that naming convention, you could also use the naming convention for the Flow Dynamic List, and have the Flow Dynamic List be filtered with Name contains 001-.
It would be great to know how you are using Custom Settings and reusable picklists in your Org, please share so that other readers have different ideas about how they can use this in their Org. Thanks for being active on the community!
This is just incredible, i am so grateful for this. Learnt something new!
Saved my life or would have had to enter dozens of values!
Keep these coming, awesome contribution to the SF community.
I have followed your guide and created picklist custom settings. I am struggling with the next part of my flow and was hoping you could help…..I have created a decision element which will have 10 potential outcomes and each will have their own dynamic choice screen. I have created the flow, however, it doesn’t seem to be hitting the decision element.
I can provide snap shots of the screen if that helps?
Any help would be great as I am now stuck!