Salesforce Data Import Wizard

In the preceding example, an entire set of records across multiple objects was being imported. For your end users, they may have more targeted requirements since they have already entered records in other objects. Also, given their skills may not be as technical, it is important to offer them a more graphical experience that requires no knowledge of JSON. For this requirement, Salesforce provides Data Import Wizard, which is available under the Setup menu.

This tool supports Custom Objects, Custom Settings, and some standard objects such as Leads, Contacts, Accounts, Campaign Members, and Solutions. Custom Metadata Type records are essentially considered metadata by the platform and, as such, you can use packages, developer tools, and Change Sets to migrate these records between orgs. There is an open source CSV data loader for Custom Metadata Types at https://github.com/haripriyamurthy/CustomMetadataLoader.

It is straightforward to import a CSV file with a list of race Seasons since this is a top-level object and has no other object dependencies. However, to import Race information (which is a related child object to Season), the Season and Fastest Lap By record IDs are required, which will typically not be present in a Race import CSV file by default. Note that IDs are unique across the platform and cannot be shared between orgs.

If you need a reminder of the structure of these objects, refer to the Schema Builder screenshot shown in Chapter 2, Leveraging Platform Features.

External ID fields help address this problem by allowing Salesforce to use the existing values of such fields as a secondary means to associate records being imported that need to reference parent or related records. All that is required is that the related record Name or, ideally, a unique external ID, be included in the import data file.

The Races.csv file includes three columns: Year, Name, and Fastest Lap By (of the driver who performed the fastest lap of that race). The following shows the content of the Races.csv file included in the sample code for this chapter:

Year,Name,Fasted Lap By
2019,Spa,LewisHamilton
2019,Melbourne,LewisHamilton
2019,Shanghai,LewisHamilton
2019,Monte Carlo,LewisHamilton
2019,Budapest,LewisHamilton

The driver in the preceding CSV file is indicated by their Twitter handle. You may remember that a Driver record can also be identified by this since the field has been defined as an External ID field. To perform the following steps, the 2019 season record and the Lewis Hamilton driver record should already be present in your Scratch org. If not, refer to the previous chapter to create these. Now, run the Data Import Wizard and complete the settings, as shown in the following screenshot:

Next, complete the field mappings, as shown in the following screenshot:

Click on Start Import and then review the results once the data import has completed. You should find that four new Race records have been created under 2019 Season, with the Fastest Lap By field correctly associated with the Lewis Hamilton Driver record.

Note that these tools will also stress your Apex Trigger code for volumes, as they typically have the bulk mode enabled and insert records in chunks of 200 records. Thus, it is recommended that you test your triggers to at least this level of record volumes. Later chapters will present coding patterns to help ensure that your code supports the bulk mode.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.38.176