You are here:
Create a .CSV File
Follow these guidelines when you prepare a .csv file for import.
Required Editions
| Available in: Lightning Experience |
| Available in: Enterprise, Unlimited, and Developer Editions |
- The first row in the .csv file lists the field names of the object to which you want to
upload the records. Think of these like the columns in a spreadsheet.For example, if you upload records to the Manufacturing Program Forecast Fact object, the first row in the .csv file looks like this.
ImportantMany objects in Salesforce are related to other objects. Keep these additional factors in mind when listing relationship fields in the first row.
- Add a reference to a related object in a CSV file.
- To describe the relationship between an object and its parent, use
RelationshipName.IndexedFieldName, whereRelationshipNameis the relationship name of the field andIndexedFieldNameis the indexed field name that uniquely identifies the parent record. - Use the describeSObjects() call in the API to get the relationshipName property value for a field.
Here’s an example of relationship fields:
AdvAcctForecastSetUseis the parent ofManufacturingProgramForecastFact.- Name is an indexed field on
AdvAcctForecastSetUse. As a result, you can useAdvAcctForecastSetUse.Nameto uniquely identify theAdvAcctForecastSetUserecord.
Note Be sure to use unique values in the indexed field. If there’s more than one record with the same value, the .csv file upload process fails with theDUPLICATE_EXTERNAL_ID:Name: more than one record found for external id fielderror.
Name,AdvAcctForecastSetUse.Name,Status,ProductionModel.Name,ProductionLocation.Name,PeriodId,ProgramQuantity,ExpectedRevenuePerUnit,MarketSharePercent,ForecastedRevenue,ForecastedQuantity,ExternalReferenceNumber - Each subsequent row corresponds to a record in Salesforce. A record consists of a series of
fields that are delimited by
commas.
FastCars AutoX Chennai JanFY2023,Fast Cars Program Set Use,Active,AutoX,Chennai,026T10000002icqIAA,500,250000,22,150000,300,FastCars AutoX Chennai JanFY2023 - Ensure that all records in a .csv file are for the same object. You'll specify the Target Object when you import the CSV file.
- Use only commas as delimiters.
- Ensure that .csv files are in the UTF-8 format.
- Ensure that all products in the .csv file have the same number of associated periods. If the products in the .csv file have unequal periods, the upload fails with an error.
- We use Bulk API to upload records. For more information on how to prepare a .csv file for Bulk API upload, see Prepare CSV Files
A car manufacturer named Fast Cars wants to launch the AutoX car in 2025. The program manager at a manufacturing supplier, Car Components, wants to forecast the program quantity, expected revenue per unit, forecasted quantity, and forecast revenue for January 2023, February 2023, and March 2023 for the Chennai and Bangalore plant locations.
Create a .csv file for program forecasts in this format.
| Name | AdvAcctForecastSetUse.Name | Status | ProductionModel.Name | ProductionLocation.Name | PeriodID | ProgramQuantity | ExpectedRevenuePerUnit | MarketSharePercent | ForecastedQuantity | ForecastedRevenue | ExternalReferenceNumber |
|---|---|---|---|---|---|---|---|---|---|---|---|
| FastCars AutoX Chennai JanFY2023 | Fast Cars Program Set Use | Active | AutoX | Chennai | 026T10000002icqIAA | 500 | 250000 | 22 | 150000 | 300 | FastCars AutoX Chennai JanFY2023 |
| FastCars AutoX Chennai FebFY2023 | Fast Cars Program Set Use | Active | AutoX | Chennai | 026T10000002icrIAA | 600 | 120000 | 15 | 97000 | 350 | FastCars AutoX Chennai FebFY2023 |
| FastCars AutoX Chennai MarFY2023 | Fast Cars Program Set Use | Active | AutoX | Chennai | 026T10000002icsIAA | 700 | 230000 | 26 | 230000 | 400 | FastCars AutoX Chennai MarFY2023 |
| FastCars AutoX Bangalore JanFY2023 | Fast Cars Program Set Use | Active | AutoX | Bangalore | 026T10000002icqIAA | 550 | 89000 | 10 | 54000 | 450 | FastCars AutoX Bangalore JanFY2023 |
| FastCars AutoX Bangalore FebFY2023 | Fast Cars Program Set Use | Active | AutoX | Bangalore | 026T10000002icrIAA | 670 | 350000 | 21 | 340000 | 500 | FastCars AutoX Bangalore FebFY2023 |
| FastCars AutoX Bangalore MarFY2023 | Fast Cars Program Set Use | Active | AutoX | Bangalore | 026T10000002icsIAA | 890 | 150000 | 18 | 450000 | 550 | FastCars AutoX Bangalore MarFY2023 |
Here's an example of the fastcarsprogram.csv file.
Name,AdvAcctForecastSetUse.Name,Status,ProductionModel.Name,ProductionLocation.Name,PeriodId,ProgramQuantity,ExpectedRevenuePerUnit,MarketSharePercent,ForecastedRevenue,ForecastedQuantity,ExternalReferenceNumber
FastCars AutoX Chennai JanFY2023,Fast Cars Program Set Use,Active,AutoX,Chennai,026T10000002icqIAA,500,250000,22,150000,300,FastCars AutoX Chennai JanFY2023
FastCars AutoX Chennai FebFY2023,Fast Cars Program Set Use,Active,AutoX,Chennai,026T10000002icrIAA,600,120000,15,97000,350,FastCars AutoX Chennai FebFY2023
FastCars AutoX Chennai MarFY2023,Fast Cars Program Set Use,Active,AutoX,Chennai,026T10000002icsIAA,700,230000,26,230000,400,FastCars AutoX Chennai MarFY2023
FastCars AutoX Bangalore JanFY2023,Fast Cars Program Set Use,Active,AutoX,Bangalore,026T10000002icqIAA,550,89000,10,54000,450,FastCars AutoX Bangalore JanFY2023
FastCars AutoX Bangalore FebFY2023,Fast Cars Program Set Use,Active,AutoX,Bangalore,026T10000002icrIAA,670,350000,21,340000,500,FastCars AutoX Bangalore FebFY2023
FastCars AutoX Bangalore MarFY2023,Fast Cars Program Set Use,Active,AutoX,Bangalore,026T10000002icsIAA,890,150000,18,450000,550,FastCars AutoX Bangalore MarFY2023
If the program manager at Car Components wants to forecast the forecasted quantity and market share percent at the variant level (Red color AutoX and Blue color AutoX) for three months (January 2023, February 2023, and March 2023) for the Chennai and Bangalore locations, they can create a .csv file for the program variant forecasts as shown in this example:
Name,AdvAcctForecastSetUse.Name,Status,ProductionModel.Name,ProductionLocation.Name,Product.Name,PeriodId,ForecastedQuantity,MarketSharePercent,ExternalReferenceNumber
FastCars AutoX Chennai Red JanFY2023,Fast Cars Variant Set Use,Active,AutoX,Chennai,AutoX Red,026T10000002icqIAA,500,22,FastCars AutoX Chennai Red JanFY2023
FastCars AutoX Chennai Red FebFY2023,Fast Cars Variant Set Use,Active,AutoX,Chennai,AutoX Red,026T10000002icrIAA,600,15,FastCars AutoX Chennai Red FebFY2023
FastCars AutoX Chennai Red MarFY2023,Fast Cars Variant Set Use,Active,AutoX,Chennai,AutoX Red,026T10000002icsIAA,700,26,FastCars AutoX Chennai Red MarFY2023
FastCars AutoX Chennai Blue JanFY2023,Fast Cars Variant Set Use,Active,AutoX,Chennai,AutoX Blue,026T10000002icqIAA,550,10,FastCars AutoX Chennai Blue JanFY2023
FastCars AutoX Chennai Blue FebFY2023,Fast Cars Variant Set Use,Active,AutoX,Chennai,AutoX Blue,026T10000002icrIAA,670,21,FastCars AutoX Chennai Blue FebFY2023
FastCars AutoX Chennai Blue MarFY2023,Fast Cars Variant Set Use,Active,AutoX,Chennai,AutoX Blue,026T10000002icsIAA,890,18,FastCars AutoX Chennai Blue MarFY2023
FastCars AutoX Bangalore Red JanFY2023,Fast Cars Variant Set Use,Active,AutoX,Bangalore,AutoX Red,026T10000002icqIAA,250,11,FastCars AutoX Bangalore Red JanFY2023
FastCars AutoX Bangalore Red FebFY2023,Fast Cars Variant Set Use,Active,AutoX,Bangalore,AutoX Red,026T10000002icrIAA,340,25,FastCars AutoX Bangalore Red FebFY2023
FastCars AutoX Bangalore Red MarFY2023,Fast Cars Variant Set Use,Active,AutoX,Bangalore,AutoX Red,026T10000002icsIAA,560,34,FastCars AutoX Bangalore Red MarFY2023
FastCars AutoX Bangalore Blue JanFY2023,Fast Cars Variant Set Use,Active,AutoX,Bangalore,AutoX Blue,026T10000002icqIAA,700,9,FastCars AutoX Bangalore Blue JanFY2023
FastCars AutoX Bangalore Blue FebFY2023,Fast Cars Variant Set Use,Active,AutoX,Bangalore,AutoX Blue,026T10000002icrIAA,650,12,FastCars AutoX Bangalore Blue FebFY2023
FastCars AutoX Bangalore Blue MarFY2023,Fast Cars Variant Set Use,Active,AutoX,Bangalore,AutoX Blue,026T10000002icsIAA,430,35,FastCars AutoX Bangalore Blue MarFY2023
Considerations for Creating a CSV File
- Populate ExternalReferenceNumber with either a unique name or number. You can use this field
during the upsert to identify existing records. For example, if you want to change the program
quantity of AutoX cars to 600 for the January 2023 period for the Chennai location, use this
format.
If a record exists in Salesforce with the same ExternalReferenceNumber in the target object, then the system updates the record with the values that are provided in the .csv file. Otherwise, the system inserts a new record in the target object.ProgramQuantity,ExternalReferenceNumber 600,FastCars AutoX Chennai JanFY2023
Note You can also use the Name field as the External ID Field API Name during the upsert operation. But if more than one record with the same name exists, the .csv file upload process fails with theDUPLICATE_EXTERNAL_ID:Name: more than one record found for external id fielderror. - You can’t use the relationship field name (
RelationshipName.IndexedFieldName) for the Period object because it has only ID as the lookup field, and you can’t customize the object to add an external ID field.

