Loading
Prepare for Email to Become the Default Login ExperienceRead More
Intermittent freezing when using using certain browser versionsRead More
Automate Your Business Processes with Salesforce Flow
Create a Parent Flow to Clone a Record Using a Child Flow

Create a Parent Flow to Clone a Record Using a Child Flow

After you create and activate the child flow that clones a record, build the parent flow that gets the source record and passes it to the child flow using a Subflow element. The Subflow element's output gives you access to the cloned record for use later in the parent flow.

Required Editions

View supported editions.
User Permissions Needed
To open, edit, create, activate or deactivate a flow using all flow types, elements, and features available in Flow Builder, including Einstein and Agentforce for Flow: Manage Flow
Note
Note You don't need to be an admin to have the Manage Flow permission. Ask your admin to add it to your profile or permission set.
Note
Note When you select the Automatically store all fields option in a Get Records element, the flow determines what fields you reference within that flow, and stores values only for the referenced fields. Therefore, if you use a Create Records element within the parent flow to clone the record, only the field values referenced within the flow are copied to the new record. When you use a child flow to clone the record, the flow copies all fields that the running user has edit access to.
  1. Open the Flows list view.
    • From the Automation app, select the Flows tab.
    • From the Flows tab in any Lightning app, click the actions menu and select Open Flow.
    • From Setup, in the Quick Find box, enter Flows, and then select Flows.
    Note that the Automation app and Flows tab options don't require Setup access.
  2. Create the parent flow.
    • From the Automation Lightning app, click New and then select the type of flow to create for your parent flow.
    • In Setup, click New Flow and then select the type of flow to use for your parent flow.
    For example, to use an autolaunched flow that can be called from other flows to clone an existing record, create an autolaunched flow.
  3. Determine how to get the record to clone.
    • In an autolaunched flow, create a text variable named recordId that’s available as input to the flow. This value is passed into the autolaunched flow and used with a Get Records element to get the record to clone.
    • In a screen flow, use a Screen element to allow the user running the flow to select a record. Use the ID of the selected record with a Get Records element to get the record to clone.
  4. To use a record ID for an autolaunched flow, add an input variable to store the record ID of the record to clone.
    1. To open the Toolbox, click Toolbox icon.
    2. Click New Resource, and then select Variable.
    3. For API name, enter recordId.
    4. For Description, enter Stores the ID of the record to clone.
    5. For Data Type, select Text.
    6. For an autolaunched flow, for Availability Outside the Flow, select Available for input.
    For example, create a text variable that’s available as input to the autolaunched flow.
    Field Value
    Resource Type Variable
    API Name recordId
    Description Stores the ID of the record to clone and is passed into the flow.
    Data Type Text
    Availability Outside the Flow Available for input
  5. To get the record to clone from the running user in a screen flow, add a Get Records element to determine which records to show the user.
    1. Click Add element plus icon, and select Get Records.
    2. Edit the generated label and description if needed. Flow Builder generates them based on the element's configuration, and the API name populates based on the label.
    3. For Object, select the object of the record to clone.
    4. For Condition Requirements, select how to evaluate the conditions.
    5. To limit the number of records to show the running user, specify at least 1 field, operator, and value. For example, to get cases that aren’t new, for Field, select Status, for Operator, select Does Not Equal, and then for Value, select New.
    6. To sort the results, for Sort Order select a value and for Sort By select the field to sort by. For example, to list newest records first, for Sort Order, select Descending, and for Sort By, select CreatedDate.
    7. For How Many Records to Store, select All records.
    8. For How to Store Record Data, select Automatically store all fields.
  6. To get the record to clone from the running user in a screen flow, next add a Screen element that contains a data table,
    1. Click Add element plus icon, and select Screen.
    2. Edit the generated label and description if needed. Flow Builder generates them based on the element's configuration, and the API name populates based on the label.
    3. From the Components tab, click Data Table..
    4. Enter an API name for the component.
    5. Enter a label to use as the title of the table and select Use Label as the table title. For example, enter Select a case to clone. Then select Use Label as the table title.
    6. For Source Collection, select the automatic output for the Get Records element from step 5.
    7. Under Configure Rows, for Row Selection Mode, select Single, and then select Require user to make a selection.
    8. For Unique Identifier, select Id.
    9. Under Configure Columns, select at least 1 field to use as a column in the data table. For each other field to use as a column in the data table, click Add column and select a field.
    10. Click Done.
  7. To get the record to clone, add a Get Records element.
    1. Click Add element plus icon, and select Get Records.
    2. Edit the generated label and description if needed. Flow Builder generates them based on the element's configuration, and the API name populates based on the label.
    3. For Object, select the object of the record to clone.
    4. For Field, select the field on the object that contains the record ID of the record to clone. For example, Case ID.
    5. For Operator, select Equals.
    6. For Value, select the variable or automatic output that contains a record ID. For example, in an autolaunched flow, select recordId. Or in a screen flow, select the entire resource of the data table component from step 6.
    7. For How Many Records to Store, select Only the first record.
    8. For How to Store Record Data, select Automatically store all fields.
    For example, to clone a case record in an autolaunched flow, add a Get Records element and set its fields.
    Field Value
    Label Get Record to Clone
    API Name GetRecordToClone
    Description Gets the case with an ID that matches recordId and stores the result in Case from Get Record to Clone.
    Object Case
    Field Case ID
    Operator Equals
    Value recordId
    How Many Record to Store Only the first record
    How to Store Record Data Automatically store all fields
  8. Add a Subflow element that calls the flow created in Create a Child Flow to Clone a Record.
    1. Click Add element plus icon, and select Subflow.
    2. In the search box, enter the name of the flow that clones a record, and then select it from the list.
    3. Edit the generated label and description if needed. Flow Builder generates them based on the element's configuration, and the API name populates based on the label.
    4. Under Set Input Values, set the input variable that contains the record to clone to Included.
      When you pass a variable to a subflow input, the variable API name can be up to 40 characters long.
    5. For the input variable that contains the record to clone, select the automatic output created by the Get Records element from step 7.
    For example, to create a copy of the case from step 7, add a Subflow element and reference the example autolaunched flow created in Create a Child Flow to Clone a Record..
    Field Value
    Search Flows Clone Record with All Fields
    Label Clone Record
    API Name CloneRecord
    Description Calls the Clone Record with All Fields flow to create a copy of the case record with a case ID matching recordId. Stores outputs from the referenced flow in Outputs from Clone Record.
    caseToClone Set to Included, select Case from Get Record to Clone, and then select Entire Resource.
    A parent autolaunched flow that clones a record. The sample flow contains a Get Records element and a Subflow element.
  9. Optional. To access the new record later in the flow, use the automatic output from step 8’s Subflow element in a Get Records element.
    1. Click Add element plus icon, and select Get Records.
    2. Edit the generated label and description if needed. Flow Builder generates them based on the element's configuration, and the API name populates based on the label.
    3. For Object, select the object of the new record.
    4. For Field, select the field on the object that contains the new record’s ID.
    5. For Operator, select Equals.
    6. For Value, select the automatic output that contains the new record’s ID.
    7. For How Many Records to Store, select Only the first record.
    8. For How to Store Record Data, select Automatically store all fields.
    For example, to get the new case record returned by the Subflow element, add a Get Records element and set its fields.
    Field Value
    Label Get New Record
    API Name GetNewRecord
    Description Gets the case with an ID that matches the case ID of the record returned in Outputs from Clone Record. Stores the result in the Case from Get New Record record variable.
    Object Case
    Field Case ID
    Operator Equals
    Value Outputs from Get New Record > newRecord > Case ID
    How Many Record to Store Only the first record
    How to Store Record Data Automatically store all fields
  10. Save the flow.
  11. Test the flow to make sure that it works as expected. Then activate it.
 
Loading
Salesforce Help | Article