Create Records Element

- Creating New Records

Create Records Element No prizes for guessing what this does!
With this element we can:
- Create a single record
- Create multiple records with one transaction (called Bulkification).

When we have exercises where you are creating a flow like this, you will be provided with all of the detailed steps. For now, we just want to introduce the concepts.
Single RecordCreating a single record is easy, we just need to assign some values then we select create a single record.

Assign Contact Values is configured as follows:
Create Contact is configured as follows:
Multiple Records
Just to repeat what was stressed earlier, we don't create records inside a loop.
Typically we use a record collection variable and create our records from that after the loop.
Example: Create a new Task for every Contact record related to an Account.
- We start from an Account Record (passing recordId of the account)
- Next we get all the related contacts We then start our loop
- For each contact record we assign new values for the task record to be created
- We then add that task record to our collection variable
- We continue looping through the contact records until we reach the last one
- We then Create our Tasks with a single element (outside the loop).

Creating Records
In this exercise, you will create a Screen flow that will allow you to input records and when you have finished, the collection of records will be saved.
Your finished flow will resemble this:

Start with a new Screen flow.
Add a variable to store one new record.

Add another variable to hold many records (a collection):

If you are using Auto-Layout, you will need to turn it off for this flow:

Create a new Screen and add these four components:

Configure the Name field as follows:

Configure the Account lookup as follows, paying close attention to 1,2,3:

Configure the phone component, make sure it is required:

Configure the Email field, also make sure it is required:

There is one more component you need to add and configure.
It is a checkbox, make sure the default value is unticked:

Next, add an assignment element to assign the values from the input screen to the r_contact record variable:

Add one more assignment element to add the single record to the record collection:
Note: The operator here is Add.
We are adding one more record to the collection, not replacing what is already in there.

Add a new decision to see if the user wants to add another record:

Add a new Create Records element:

Finally, join up all the elements so it looks like the image at the start.

Save, activate and run your flow in debug mode:

You should now be able to create multiple contact records
No comments:
Post a Comment