Is it possible to Import data from an Excel file to CRM via Flow?
What are the possible CRM actions?
Create, Update and Delete.
What if we need to Update existing records and Create the non existing ones? Would this still be possible via flow?
Unfortunately, there isn't an action called UPSERT that enables us to accomplish that functionality.
In this post, we will explore the way realizing the UPSERT functionality.
Example: I need to Import contacts from within an excel file with the following columns: Email, Name, Surname and Phone Number... I need to Update the infos of each contact whose email is found in CRM and Create the ones not found.
0. GLOBAL FLOW STRUCTURE:
The Excel file will be placed in a OneDrive folder.
We will Obtain Excel lines of the uploaded file.
Initiate a variable to detect if it's an Update or Create.
Add an "Apply to each" loop to pass over all the Excel Lines and do the action of Updating or Creating.
1. OBTAIN THE EXCEL FILES:
Put the file name: by searching for the right folder (ex: /WeezEvent/) + filename (New Microsoft Excel Worksheet.xlsx).
Choose the Excel Table name: You must have your Excel data inside an Excel Table in order to be able to import the file via flow.
2. ADD AN INIT VARIABLE:
Choose the name of the variable: ExistContact in our example.
Choose its type: Boolean in our case.
Initiate it with a value: false in our case.
3. ADD AN APPLY TO EACH LOOP:
3.1. Add a condition to check if Email contains data:
In the condition filters, choose the KEY column of the Excel file that will let you differentiate between a Create and an Update and test it not being empty (null).
In our example, if the Email (our contact key) is not null -> we need to perform our CRM actions.
3.2. Perform CRM Actions:
Three main steps to do in case the Email column of each Excel row is filled:
List CRM contact records having a matching Email.
Change the status of the Boolean variable in case a Contact record is found in CRM + Update the contact record
Create the contact in case it is not found.
Note that the "Apply to each" loop will perform the 3 steps for each line of the Excel file table.
3.2.1. List Records:
Inside the filter query, type the technical name of your field (emailaddress1 in our example) + eq + Add the corresponding Excel Column.
Result: Getting the list of contacts in CRM with their emails = Excel email column of the Row.
3.2.2. Add an apply to each loop to the found CRM records:
Add the Apply to each loop
Set the variable value to: true
That step will set the value of our "ExistContact" Boolean field to true just in case at least 1 record is found with the corresponding Email in CRM.
3.2.3. Test if it's an UPDATE or CREATE then do the Action:
At this point, we will realize 2 main steps:
Add a condition to check the Boolean variable's final state
Perform the Create or Update CRM action.
22.214.171.124. Add a condition
Test if the variable "ExistContact" is equal to false
IF YES: The contact wasn't found in CRM and we must CREATE it.
IF NO: One or more Contacts have been found and we need to Update them.
126.96.36.199. Add CRM Actions correspondingly
IF YES: Create the record
IF NO: (Boolean field = true) we need to reset the Boolean field to false then Update the contacts having been found.
NB: The Boolean field must be reset in order to work properly for the next Excel Line.
4. RECAP IMAGE OF THE FLOW:
PS: Do not forget to assign in the UPDATE and CREATE the EXCEL COLUMNS that you need to Insert in CRM fields.