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
filemapping
it also exists in the record mapping. -
It is required that the
field
element be paired with either avalue
element orcolumnreference
element. -
If you specify the
line
element forrecordmapping
, do not specify a value for thefilemapping
element. -
When mapping to the standard form for custom records, specify an empty
entryform
element andCUSTOMRECORD
as the record type, for example:<savedcsvimport scriptid="custimport_customrecord34"> ... <customrecord>[customer_details]</customrecord> <recordtype>CUSTOMRECORD</recordtype> ... <entryform/> ... </savedcsvimport>
The empty
entryform
element 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
transactionform
element andCUSTOMTRANSACTION
as the record type, for example:<savedcsvimport scriptid="custimport_customtransaction68"> ... <customtransaction>[scriptid=customtransaction_material_invoice]</customtransaction> <recordtype>CUSTOMTRANSACTION</recordtype> ... <transactionform/> ... </savedcsvimport>
The empty
transactionform
element 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 recordmapping
s
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
STDEMAIL
field 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
STDMEMO
field 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
STDPHONE
field is mapped to the Phone Number column in theSALESORDER
CSV 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
STDCUSTOMER
field is mapped to the Customer EID column in theSALESORDER
CSV 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.