- Salesforce Blogs -

How to Update, Insert, Export or Delete Data Using Apex Data Loader?

Data loaders are available in Salesforce Classic and Lightning Experience but not in all organs. Before we learn how to insert, update, export, and delete data using data loader, let us first discuss what is a Data Loader and data types supported by Data Loader. After this, we will learn using data loaders in the Salesforce. To import data, data loaders read, extract, and load data from CSV files or from a database connection. When data is exported, it gives CSV file as the output.

Data loaders can be used in two different ways either User Interface or Command Line Interface. With User Interface, you can specify configuration parameters interactively. When we use Command Line Interface, you can specify mappings, configuration, or data sources in files. Here are the important features offered by the Data Loader:

  • It is an easy-to-use wizard interface for interactive use.
  • It is an alternative command-line interface for automated batch operations that can be used for Windows only.
  • It is used to process data in the Salesforce.
  • It supports larger files up to 5 million records
  • It supports drag-drop field mapping.
  • It supports all types of objects including custom objects too.
  • It shows detailed error log files in the CSV format.

salesforce Curriculum

When to use Data Loaders?

Data loader complements the web-based import wizards that are accessible through the Setup Menu in an online application. Here are the guidelines to check when to use Data Loaders.

  • You can use data loader when you want to load 50K to 5 million records together. To load more than 5 million records, we recommend you to take help of a Salesforce Partner or visit the App Exchange for a suitable partner product.
  • You can load an object that is not supported by import wizards.
  • You can schedule regular data loads based on requirements.
  • You can export data for backup purposes.

You should use data imports when:

  • You want to load less than 50k records.
  • The object you want to import is supported by the import wizard.
  • You want to avoid duplicate values by uploading records based on the account name, email address, website address etc.

How to use Data Loaders?

Using Data Loader, you can perform multiple functions like export data, field mapping, insert data, delete data, update data etc. You may load attachments too and review the output files closely. First, we need to understand the data types supported by Data Loaders.

These are given as below.

  • Base 64: This data type is used to insert or update attachments. It is used to update Salesforce content too.
  • Boolean: This data type is used to support Yes or No type values either True or False.
  • Date Formats: To give dates in different formats, this data type is suitable. To use the date format that supports the day at the beginning instead of a month, you should choose the European date format here.

To use GMT format, we recommend you to change the computer settings to the GMT in order to avoid adjustments when you insert or update records. Dates are generally valid within a certain range only and they are offset by the time zone.

  • Double: it is used to support the standard double string.
  • ID: Salesforce ID is case sensitive that uniquely identifies a record.
  • Integer: It is used to support a standard integer string.
  • String: It supports valid XML strings and invalid XML strings are removed.

free salesforce demo

How To Export Data Using Data Loaders In The Salesforce?

To extract data from a Salesforce object, you can use data loader export wizard. Here are the step by step instructions to help you.

  1. Open the Data Loader.
  2. Click on Export option. To export the archived activity reports and soft-deleted records, use the Export All option.
  3. Now login to your Salesforce account with valid Username and the Password.
  4. Once you are logged in to your account, Click on Next option.
  5. When your organization restricts IP addresses then access from untrusted IPs is not allowed. In this case, Salesforce will send an email itself that can be used to log in. the email will give you a security token to add at the end of the password. With this process, you can log in to Salesforce even from untrusted IPs.
  6. Choose an object, if your object is not listed then select “Show All Objects” option and it will give you a list of objects that you may access.
  7. Now decide on the CSV file to export the data. You may either choose the existing file or create a new one too. When you select an existing file, the export option will replace its content. To confirm the action, click on YES otherwise choose NO.
  8. Click on the NEXT option now.
  9. Now generate a SOQL query to export the data. For example, you may select ID or Name in query fields and click on FINISH. When you select the Next option, the CSV viewer displays all account names and their IDs too. Similar to the SELECT statement in SQL, SOQL also helps you to retrieve the selected rows in the source object.
  10. You may choose fields to export. You may set conditions to filter datasets. If you don’t select any condition, all data to which you have read access will be returned. Review the generated query and edit it if necessary.
  11. Now click on Finish then click on Yes to confirm.
  12. When the operation is completed successfully, you may view the CSV file by clicking on View Extraction and click OK.

Note: Data Loader doesn’t support exporting attachments. For this, use the workaround feature in the weekly report to export attachments. If you select compound fields to export data in the Data Loader, it will cause errors. To export values, choose components individually. salesforce quiz

How to Insert, Update, or Delete Data Using Data Loader?

You can use data loader to add modify or delete the data records. The upsert wizard helps to insert or update the data together. If a record matches the existing record then the value is updated with the values in your file. If no matches are found then a new record is created. When records are hard-deleted then they are eligible for deletion and added to the recycle bin.

User Permissions Needed
To Insert Records: Create on the Record
To Update Records: Edit on the Record
To Upsert Records: Create or edit on the record
To Delete Records: Delete on the Record
To Hard Delete Records: Delete on the Record
To Mass Delete Records: Modify all Data

At the same time, soft-deleted records can be exported again if required.

  • Open the Data Loader. Click on update, upsert, delete, export option based on requirements.
  • Now login to your Salesforce accounts with valid Username and the Password. Once you are logged in to your account, Click on Next option. When your organization restricts IP addresses then access from untrusted IPs is not allowed. In this case, Salesforce will send an email itself that can be used to log in. the email will give you a security token to add at the end of the password. With this process, you can log in to Salesforce even from untrusted IPs.
  • Choose an Object. If you want to add Account Records then select Account. If your object does not display here then select show All objects option. Keep in mind that data loader deletes the data based on ID, not on the basis of the object selected.
  • Now select the CSV file. Click on Next.
  • Once CSV file and object are initialized, click OK.
  • If you are performing an upsert operation then the file must contain a column of IDs for matching again existing records. The column is either an external ID or Salesforce Record ID. From the drop-down list, select which fields to use for matching. In case, the object has not external ID, Salesforce record ID is used. Click on Next to continue.
  • In case, the file includes the external ID having a relationship with the chosen object enable the external ID for record matching by selecting its name from the drop-down list. If you make no selection then you may choose related object’s ID field for matching by mapping it in the next step. Click Next to continue.
  • Define how columns should be matched in your CSV file map to Salesforce fields. You can choose existing field mapping or create a new one as required. Click Next.
  • For each operation, data loader generates two separate CSV log files. One file name starts with prefix Success and another file name starts with the prefix error. Click on Browser to specify a directory for these files.
  • To complete a particular operation, click on Finish then click Yes to confirm. When the operation precedes, a progress window shows the status of data movement.
  • To check the success or error files, Click View successes and View Errors. To close the wizard, Click Ok.

How to Update, Insert, Export or Delete Data Using Apex Data Loader? When you are deleting or updating massive data together, you should perform mass updates and mass deletes operations. If you get timeout error during file uploads then divides the file into smaller parts for easy handling. In this way, you can insert, update, delete, or export data using Data loaders within minutes. To know more, join the Salesforce certification program at JanBask Training and learn everything in detail.

    Janbask Training

    JanBask Training is a leading Global Online Training Provider through Live Sessions. The Live classes provide a blended approach of hands on experience along with theoretical knowledge which is driven by certified professionals.


Comments

Salesforce Upcoming Batches

Mon - Fri

6 Weeks

Mon - Fri

6 Weeks

Newsletter