How to Import Salesforce contacts from a CSV
file using UiPath Studio In this example, we will create a workflow
that will automatically upload contacts from a CSV file into your Salesforce account. Lets say, you have already have a Salesforce
account and you want to import contacts. I will using the most common standard csv format.
Here have an example of a CSV file with Last Name, First Name, Phone and Email Address.
Let’s open UI Path Studio and Create a new workflow by clicking the New workflow box.
Let’s delete the default Opening Sequence so we can start a new one.
The whole automation process will start from opening the web browser, logging in to the
account and entering the data. Let’s start by telling UIPath to imitate our manual actions.
Let’s click on the Record button and Click Record Web
You can type in the full URL in the URL box or you can just put in – salesforce.com. Let’s
leave everything to default. We’ll use IE as our browser.
Let’s click Open. This will open the salesforce website automatically in Internet Explorer.
Now we are in the recording mode. As you can see there’s an orange box every time we
are highlighting an element in the page that’s because UiPath recognizes each element of
the page in which actions can be performed. That means the automation still works. No
matter where the location of the element is. Let’ highlight the Login button and Click
on it. Log in using your Salesforce administrator account. Let’s put in the email address.
This will gives you this pop-up window. Just put in the data and press Enter. Let’s do
same with the password. Then click the Login button. Now that we are logged in, we are ready to
input new data. Go to the contacts tab. Click on New contact.
Let’s fill in the Contact information: Let’s put in the required fields which are highlighted
with a red bar. Let put in the First Name, Last Name. For account name, let’s put in
Salesforce – this is the default for a new Salesforce account. Then email address, phone
number. We are basing the other information from our CSV sample.
Let’s say we have more data to fill out but we need to scroll the page. We can’t
do that since we are on the recording mode. Here’s what we can do, You can press F2
to stop the recording mode in few seconds then we can scroll down the page. There, we
are now ready to fill out more info. When its complete, Click Save and New. And
we are ready to enter new data. But we will stop the recording now. All actions we needed
for the automation process are done. Let’s Press ESC to stop recording and click
Save and Close. Our new Record Sequence will be in our workflow. We can now connect the Recording Sequence
as our Start node by dragging this line to it.
We are ready to test our Recording. But let’s close the Internet Explorer window first.
Go to the Execute tab and click Run button. You can also press F5 as a shortcut.
By the default, before performing an action, the UI path waits for the page to start loading
until the full webpage is loaded. Let’s now create an action to open our CSV
file and capture data from it. In the Activities Bar, search for Read CSV.
Drag and the drop it to the workflow, then double click to open it. Now let’s click
this button to specify the location of the CSV file.
Let’s Go back to the Main window of the workflow. Let’s make this as a start node.
Right-click on it and select Set as Start Node.
The output of this Activity will be stored in a variable which UIPath uses to store and
transfer data between activities. In this case, we will use the data from the CSV file
and store it in a DataTable format. The variable name for the Output value is
set automatically but let’s rename it to make it more readable. Let’s name it dtContacts”.
We’re going to use this later on. Next, we will create an activity that will
fetch the data from the CSV file. Let’s find “For Each Row in Datatable”
in the activities bar. What it does is it will perform a loop to pick up all the data
from the data table in each row. Let’s change the reference variable by changing
this into dtContacts so it will read our CSV file.
While we are on this For Each activity, Let’s give it an output by using a write line action.
Let drag it here in the body. Then type in row(“Last Name”).ToString. This expression
will convert the value from the Last Name from the header of the CSV file to a text
format. Let’s do some test first. Let hit F5 to
run the current workflow. In the Output window, It gives Smith and Ryan. So it works!
Now we are ready to produce the output in Salesforce. Let’s move this into the Recorded
Sequence. Right click on it and select cut. Let’s put it here – right after the the
“New” button has been clicked. I am going to move the action that I wanted
to be repeated inside the “Body” of the For Loop.
Let’s now change the manual inputted values into the value of the data table so I am going
to change this to row(“First Name”).ToString Let’s leave the account name to “salesforce”
since data won’t be changed. What I am putting here is the Exact letter
the CSV file. Ok we’re done.
Let’s make the last changes in the workflow by connecting all the activities.
Let’s rename this to “Salesforce import” Alright, we’re done! Let’s now see it
in action! Let’s execute the workflow by pressing F5. There as you can see. By just one click. It
performs the actions automatically. It logs in. It goes to the Contacts page and enter
the values from the CSV file. That’s it! Now you have a solution of importing
large amount of data to your Salesforce contacts or other CRM Software!
For more helpful tips and tutorials go to support.uipath.com. Thanks for watching!