I have two objects that are related via Master Detail through a junction object. Lets call it ObjectA, ObjectB, JunctionObjectC.

I have flow that creates Object A and stores the new record ID. Later in the flow I have a Dynamic Choice List of ObjectB records. I am showing the name of the record as the label and the record id as the value.

I want to create a new junction record associated to the newly stored ObjectA record and every ObjectB record that was chosen in the Dynamic Choice List.

I thought I could achieve this by using the Dynamic Choice list as the value for the ObjectB Value via Record Create.

Can Record Create be used to create multiple records? Any other thoughts would be appreciated.

I suspect the answer is no - any workarounds?

I found this doc...


From what I understand - you cannot dynamically create records based on a multi select dynamic choice list.

I have to place a limit on the number of record creates simply because I cannot dynamically create variables from alist of multi select dynamic choices.

All the same - How do I assign dymnamic multiselect checkboxes to vairables?

4 Answers 4


In the Winter '15 release of Salesforce, they are introducing new collection support in Visual Workflow (aka Flow).


Store multiple values together—so that you can operate on them—by using the new collection variable flow resource. Collection variables can store both manually entered values and values from flow resources, such as email addresses entered in a flow’s screen. Using collection variables can help you conserve limits by not querying the Salesforce database for that information.

Previously, you couldn’t store manually entered values or values from another flow resource. Both sObject variables and sObject collection variables can store multiple values, but they must be field values.

Create a collection variable from the Resources tab in the Cloud Flow Designer by double-clicking Collection Variable.

Unlike with variables, sObject variables, and sObject collection variables, you can’t use Record Lookup or Fast Lookup elements to populate a collection variable. To populate a collection variable, add values whose data type matches the collection variable by using an Assignment. In other words, don’t try to add a variable of type Text to a collection variable of type Number.

collection assignments



Feedback posted on the discussion of this post. "Collection Management in Flow" is on the road map and is top priority. From the discussion it sounds like Collection Management will better incorporate Dynamic Choices in Flow.

Currently the only way to accomplish this is via a Apex Plugin.


I struggled with this for a while. I really needed a way to have Flow walk my users through a wizard that would collect the necessary data to automatically create a contract. The issue is that I wanted to use the Dynamic Choice to load the product list as multi select checkboxes. The flow would then create the contract, and take the multiselect checkboxes and add detail records to a junction object (junction between Products and Contracts). Flow cannot do this, so I have flow do an Assignment step to store the multiselect fields in a variable. It is a bunch of Ids separated by semicolons. This is saved in a long text field on the contract that doesnt appear on the layout. I then wrote an after insert Apex Trigger for the Contract object that takes the text field, parses it for Ids that are stored in a list, then are inserted as detail records. Voila! Creating ObjectA in Flow (along with the necessary info for the Trigger to work) and a Trigger to create the child ObjectBs!

trigger AddProductstoSOW on PS_Contract__c (after insert) {
for(PS_Contract__c c : Trigger.new){
    List<String> strProductIds = c.Initial_Services_Selected__c.split('; ', 1000);
    List<SOW_Task__c> tasks = new List<SOW_Task__c>();
        for(String i : strProductIds){
        SOW_Task__c s = new SOW_Task__c();
        s.PS_ServiceNo__c = i;
        s.PS_Contract__c = c.Id;
     insert tasks;
catch(DmlException e) {
System.debug('An unexpected error has occurred: ' + e.getMessage());

enter image description here


This can (now?) be done totally in Flow. The trick is, you'll need to store all the objects in the picklist (your object b) in an sObject collection. So, before or after your dynamic choice is made, you'll need to have a step to perform a quick lookup and store the same results in the sObject Collection, let's call this collection "sOC". Now that you have all of the possible choices one could pick in the sOC, after the dynamic choices are made, you need to run a loop to match the choices made to the sOC, using the sOC as the loop controller.

Here comes the cool part. In your loop, your first step will be to have a decision step to compare the results from the dynamic choice step to the object you've created in the loop step (I would have called it sOCObjectContainer). Don't forget, you need to use the sOCObjectContainer.Id as the value to compare to the values of the dynamic choice variable. Once you get a positive match, leading into the further steps in the the loop, you need to assign the values of the sOCObjectContainer into a new sObject collection. Something like "sOCObjectsToSave". You can also assign values to another variable for a confimation page, which you can show the user before the final save of sOCObjectsToSave is made (and after your loop is finished). Also don't forget, the other side of the decision to match the dynamic choices (No Matched decision path) has to go back to the loop to have it continue on no match.

I hope that makes sense and helps.


You must log in to answer this question.

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