EP - 06 | UPDATE CONTACT RECORDS WITH FLOW | LIGHTNING FLOW SERIES

 


Update Record Element

In this blog you will learn how to use Update Record Eelement to update an existing record in any object using salesforce flow.

What is Update Record Element?

As the name suggests this element is used for updating a record using salesforce. So, If you want to update a contact, case, account or any other custom object you don't have to write apex code to do that anymore. You can do it easily by creating a flow.
In the Update Records element, your selection for how to identify the records to update and set their values determines what to enter in the rest of the element.

Use a record variable or record collection variable

If you’ve populated a record variable or record collection variable with the field values to change, choose to use the IDs and field values from a record variable or record collection variable, and then select the variable to use. To update the field values in a record variable or record collection variable, configure an Assignment element earlier in the flow.
When you use a record collection variable to update multiple records at once, you reduce the number of DML requests in your flow. That means you’re more likely to stay within your org’s limits.

Use conditions and set fields individually

Otherwise, choose to use conditions and set fields individually. Choose the object whose records you want to update, add conditions to filter down the list of records, and set the field values to change for those records. You can update any field on the record, but the Update Records element doesn’t know which fields are required for this object.
Configure at least one filter condition, or the flow updates all the records for the object.

Use Case :
Client wants to update every contact's title, department and language which is related to an account.

For this we will create a Screen Flow and ask the Client what should be the Title, Department and Language for all the Contacts and add that flow to Account Record Details page.

To achieve this first we will add a Screen Element on the canvas first. Have a look at it below :


In this screen element we will ask the user to fill in Department, Title and Language. After that we will add an Update Record Element to update all the Contact related to an Account. But for that we will have to get the AccountRecordId first.
We will place this flow on account record details page and to get the recordId from a detail page is very simple. We will create a variable with the Api Name recordId and data type text.

Have a look :


After that we will take an Update Record Element :



In this element first of all we will choose the object we want to update. We have chosen Contact here. After that we will add a condition that only update those record whose AccountId is equals to recordId variable that we added earlier.
After that we have a section to set the fields that we want to update. In which we will add all of the three fields and that is it.

After adding it we will just add a success screen to show that updating is done.


Have a look at our output :


To check the complete details video checkout my youtube video :

If you have any question please leave a comment below.

If you would like to add something to this post please leave a comment below.
Share this blog with your friends if you find it helpful somehow !

Thanks
Let's learn and grow together.
Love and Peace! 🧡

Post a Comment

0 Comments