How to Create a Related Record from a Salesforce Flow

In Salesforce automation, we use flows to automate the data process in the org, like creating, deleting, or updating a record using the flow. In this Salesforce tutorial, we will learn about creating a related Record from a Salesforce flow.

Create a Related Record from a Salesforce Flow

There are two ways to create a related record using the flow in Salesforce:

  • Create a Related Record using the Screen flow
  • Create a Related record using the Record Triggered flow

Create a Related Record from a Salesforce Screen Flow

To create a related record from Screen flow, navigate to the Setup page of Salesforce and follow the below steps.

1. On the Setup page, go to the Quick Find box, then search and select Flows.

Create a related record with Salesforce Screen flow

2. In the Flows setup window, click New Flow.

Create a Screen flow to related record in Salesforce

3. Select the option Screen Flow and click Create.

How to create related record with Salesforce flow

4. In the flow, click on the “+” icon and add the Screen element.

Use Screen flow to create related record in Salesforce

5. In the New Screen, enter the Label and API Name for the screen, then add the Text component to the screen.

Use Salesforce flow to Create related records

6. Here, I have added two text components with the labels First Name and Last Name. These text components will take input from the users to create contact records.

After this, activate the Require checkbox and click Done.

Salesforce flow to create related record in object

7. Add a Create Records element to the screen flow.

Create a related record with Salesforce flow

8. Enter the Label and API Name for the Create record element. Then, activate the radio button. Use separate resources and literal values.

See also  How to Create Lookup field in a Salesforce Flow

In the Object field, select the related record object (Contact).

Create related contact for Account with flow in Salesforce

9. In the section, Set Field Values for the Contact, map the object fields with the text components that we have created in the screen element in the above steps.

Create related records in Salesforce using Screen flow

10. Add another field, AccountId, that will relate the created contact to the account. In the value field, click and select the option New Resource.

Create a Screen flow to create related records in Salesforce objects

11. Enter the details to define the new resource.

  • Select the Resource Type as a Variable.
  • Enter the API Name as RecordId.
  • Enter the Data type as Text.
  • Activate the checkbox available for input.
  • At last, click Done.
How to Create a Related Record from a Salesforce Flow

12. Now the screen flow is completed, here click on the Save button.

Salesforce screen flow to create related records

13. Enter the Flow Label and the Flow API Name will be auto-filled according to the entered label. After this, click Save.

Use Salesforce Screen flow to Create related records

14. Click on the Activate button to activate and use this flow.

Create a related records using Salesforce flow

Add the Screen flow to the record page

In this example, this screen will create related records (contacts) for the account object, so I’ll add this flow to the account record page.

To add this flow on the record page follow the steps below.

1. Navigate to the Accounts tab -> select any record -> click on the settings icon -> select Edit Page.

Use Salesforce flow to Create Contacts

2. In the Lighting app builder, drag the Flow component from the left sidebar to the template region.

3. In the right-hand sidebar, select the created flow in the Flow field, then activate the checkbox Pass record id into this variable.

See also  How to use Collection Filter in Salesforce Flow

After this, click Save to apply changes.

Create a Screen flow to create related records in Salesforce

4. On the Account record page, enter the first name and last name in contact details, then click Next.

Salesforce screen flow to create related records in parent record

5. Now, the contact will be created, and it can be viewed in the Contacts of the account record.

How to use Salesforce Screen flow to Create related records

In this way, we can create a related record from a Salesforce Screen Flow by following the above steps.

Create a Related record using the Record Triggered flow

To create a Related record using the Record Triggered flow, navigate to the setup page of Salesforce and follow the below steps.

1. Navigate to the Setup page, then search and select Flows in the quick find box under the heading Process automation.

2. In the Flows setup window, click on New Flow.

how to create related record from parent record using flow in Salesforce

3. In this step, select the option Record triggered flow and click Create.

Use Record trigger flow to create a related record in Salesforce

4. In the Object field, select Account (parent object). For the trigger condition, select the option, A record is created or updated.

Select the Condition Requirements as All Conditions Are Met (AND).

Here, the defined condition is that the trigger will run when the Active field is selected as True (yes).

How to Create a Related Record from a Salesforce trigger flow

5. Add a Create Record element to the flow.

Use Salesforce trigger flow to create related records

6. Enter the Name and API Name for the create record element.

In the section, How to set the record, select the option Use separate resources and literal values. Then, in the Object field, select the object of the related record (Contact).

Create a related record with record trigger flow in Salesforce

7. In the section Set Field Values for the Contact, set the Fields with their Values. In this flow to create the Contact record in Account, I have set the AccountId field with the value Record.Account ID, and another field is the Last Name field with the value Record.Account Name.

See also  How to Create Roll-Up Summary Field using Salesforce Flow

The last name will take the name of the parent object record, which can be modified later in the record page.

How to Create a Related Record using trigger flow in Salesforce

8. Click on the Save button at the top.

Create a related record with Salesforce trigger flow

9. Enter the Flow Label to save the flow, and the Flow API Name will be auto-filled according to the entered flow label.

After this, click the Save button.

Create a Record trigger flow for creating related records in Salesforce

10. Activate the created record-triggered flow, and for that, click the Activate button.

Salesforce trigger flow to create related records

After activation, when the applied condition in the flow will trigger the related record will be created in the parent object record.

In this way, we can create related records in Salesforce using the Record triggered flow by following the above steps.

Conclusion

In Salesforce CRM, flows help enable the automation of various processes; with this automation, we create a related record. In the above steps, we have created the related record of Contact for the parent Account record using the Screen flow and record-triggered flow.

By following the above steps, you will be able to use the screen flows and record-triggered flows to create the related record of the parent object record in your Salesforce instance.

You may like to read: