Defining Record and Field Mappings for Saved CSV Import Maps in XML Definitions
When your users import CSV files, the data is imported based on the mappings you define for records and fields. In SuiteCloud Development Framework (SDF), the record and field mappings are defined in the savedcsvimport SDF custom object.
To define mappings, see the following topics:
Consider the following when creating mappings:
-
SuiteCloud IDE plug-in does not validate field mappings. To ensure you are mapping to valid fields, use the Import Assistant.
-
It is a best practice that if a record exists in the
filemappingit also exists in the record mapping. -
It is required that the
fieldelement be paired with either avalueelement orcolumnreferenceelement. -
If you specify the
lineelement forrecordmapping, do not specify a value for thefilemappingelement. -
When mapping to the standard form for custom records, specify an empty
entryformelement andCUSTOMRECORDas the record type, for example:<savedcsvimport scriptid="custimport_customrecord34"> ... <customrecord>[customer_details]</customrecord> <recordtype>CUSTOMRECORD</recordtype> ... <entryform/> ... </savedcsvimport>The empty
entryformelement corresponds to the standard form as the default selection in the NetSuite user interface Import Assistant. -
SDF only permits the preferred form to be specified in a saved CSV import of a custom transaction. To map to the preferred form for a custom transaction, specify an empty
transactionformelement andCUSTOMTRANSACTIONas the record type, for example:<savedcsvimport scriptid="custimport_customtransaction68"> ... <customtransaction>[scriptid=customtransaction_material_invoice]</customtransaction> <recordtype>CUSTOMTRANSACTION</recordtype> ... <transactionform/> ... </savedcsvimport>The empty
transactionformelement corresponds to the preferred form as the default selection in the NetSuite user interface Import Assistant. -
The Queue Number field is not supported.
-
Do not reference a record using the default value. The default value is different across accounts.
Record Mappings
Record mappings are defined using a collection of recordmapping elements with the recordmappings element.
For more information about records, see the following topics:
-
For the list of possible record type values, see csvimport_recordtypes.
-
For information about records supported by saved CSV import maps, see Supported Record Types for CSV Import.
During deployment, the internal IDs for records are based on values in the target account and not the values in the CSV file. If needed, you can override those IDs by using SuiteBundler to deploy the object.
The following example defines recordmappings for the SALESORDER record type and SALESORDER:ITEMS subrecord type.
<recordmappings>
<recordmapping>
<record>SALESORDER</record>
<fieldmappings>
...
</fieldmappings>
</recordmapping>
<recordmapping>
<record>SALESORDER:ITEMS</record>
<fieldmappings>
...
</fieldmappings>
</recordmapping>
</recordmappings>
For examples of field mappings, see Field Mappings. For a complete savedcsvimport SDF custom object example, see Saved CSV Import Maps XML Definition Example.
The line element is used with the recordmapping element when sourcing a list from a single file. You should use the NetSuite user interface Import Assistant to ensure the CSV columns are correctly mapped to lines. When line element is used, there is no value for the filemapping element.
The following example defines field mappings for two address lines in the customer contact address book:
<recordmapping>
<line>1</line>
<record>CUSTOMERANDCONTACT:ADDRESSBOOK:ADDRESSBOOKADDRESS</record>
<fieldmappings>
<fieldmapping>
<field>ADDR1</field>
<columnreference>
<column>street2</column>
<file>CUSTOMERANDCONTACT</file>
<type>NAME</type>
</columnreference>
</fieldmapping>
<fieldmapping>
<field>ADDR2</field>
<columnreference>
<column>city2</column>
<file>CUSTOMERANDCONTACT</file>
<type>NAME</type>
</columnreference>
</fieldmapping>
</fieldmappings>
</recordmapping>
<recordmapping>
<line>2</line>
<record>CUSTOMERANDCONTACT:ADDRESSBOOK:ADDRESSBOOKADDRESS</record>
<fieldmappings>
<fieldmapping>
<field>ADDR1</field>
<columnreference>
<column>street3</column>
<file>CUSTOMERANDCONTACT</file>
<type>NAME</type>
</columnreference>
</fieldmapping>
<fieldmapping>
<field>ADDR2</field>
<columnreference>
<column>city3</column>
<file>CUSTOMERANDCONTACT</file>
<type>NAME</type>
</columnreference>
</fieldmapping>
</fieldmappings>
</recordmapping>
Field Mappings
A field mapping is defined by the fieldmapping element as part of a fieldmappings collection, and grouped by record using the recordmapping element. For a list of fields and values, see savedcsvimport.
For information about field mappings, see the following:
Field mappings are defined by record type. For examples of record type mapping, see Record Mappings.
Field descriptions can be found in the SuiteTalk Schema Browser. Field information is also available in the NetSuite user interface form for the selected record type. You can click the field label to display help that describes the field.
To be available for mapping, the field must be both exposed to CSV import and available to you to map. You can use the NetSuite user interface Import Assistant to determine the fields that are available to you. The list of available fields can be impacted by your permissions and the features that are enabled for the target NetSuite account.
You can define a field mapping the following ways:
-
Specify the default value.
In the following example, the
STDEMAILfield is mapped to an email address as the default value.<fieldmapping> <field>STDEMAIL</field> <value>jmiller@example.com</value> </fieldmapping> -
Specify a null value.
In the following example, the
STDMEMOfield is mapped to a null value.<fieldmapping> <field>STDMEMO</field> <value/> </fieldmapping> -
Map the field to a column in a CSV file.
In the following example, the
STDPHONEfield is mapped to the Phone Number column in theSALESORDERCSV file.<fieldmapping> <field>STDPHONE</field> <columnreference> <file>SALESORDER</file> <column>Phone Number</column> </columnreference> </fieldmapping> -
Map the field to a column in a CSV file with the reference type.
In the following example, the
STDCUSTOMERfield is mapped to the Customer EID column in theSALESORDERCSV file with a reference type ofEXTERNAL_ID.<fieldmapping> <field>STDCUSTOMER</field> <columnreference> <file>SALESORDER</file> <column>Customer EID</column> <type>EXTERNAL_ID</type> </columnreference> </fieldmapping>
For a complete savedcsvimport SDF custom object example, see Saved CSV Import Maps XML Definition Example.