This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Working with Create in NetSuite



Overview

The following operations allow you to work with "create". Click an operation name to see details on how to use it.

For a sample proxy service that illustrates how to work with "create", see Sample configuration.

OperationDescription

addList

Adds records into the system.

attachAttaches a record or file to another record.
initializeListInitializes a new list.

Operation details

This section provides details on the operations.

Adding a list

The addList operation is used to add one or more new instances of a record to NetSuite. If there are multiple records, they can either be of the same record type or different record types. For example, it's possible to add a customer and a contact within a single request using this operation. However, each record entered must have a unique signature. Adding two records with the same signature results in a SOAP fault. The signature consists of parameters required to identify a record as unique.

For example, in the case of entities, a record is uniquely identified by its name, type, and parent hierarchy. So you could have two records with the same entityId (or name) belonging to two different record types as follows:

Customer (the type): John Smith

MyCompany: John Smith

Contact: John Smith

But a second record such as the following would be invalid: 

Contact: John Smith

 

addList
<netsuite.addList>
 	<records>{$ctx:records}</records>
</netsuite.addList>
Properties
  • records: One or more records that need to be added. Contains an array of record objects.

Sample request

Following is a sample SOAP request that can be handled by the addList operation.

Sample Request for addList
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="wso2.connector.netsuite.addlist">
  <soapenv:Header></soapenv:Header>
  <soapenv:Body>
  	<urn:apiUrl>https://webservices.na1.netsuite.com/services/NetSuitePort_2014_1</urn:apiUrl>
    <urn:warningAsError></urn:warningAsError>
    <urn:disableMandatoryCustomFieldValidation></urn:disableMandatoryCustomFieldValidation>
    <urn:disableSystemNotesForCustomFields></urn:disableSystemNotesForCustomFields>
    <urn:ignoreReadOnlyFields></urn:ignoreReadOnlyFields>
    <urn:partnerId></urn:partnerId>
    <urn:applicationId></urn:applicationId>
    <urn:email>user@gmail.com</urn:email>
    <urn:password>123</urn:password>
    <urn:account>TVTDRV1193710</urn:account>
    <urn:roleInternalId></urn:roleInternalId>
    <urn:roleExternalId></urn:roleExternalId>
    <urn:roleType></urn:roleType>
    <urn:roleName></urn:roleName>
    <urn:records>
  	  <platformMsgs:record xmlns:RecordRef="urn:core_2014_1.platform.webservices.netsuite.com" xmlns:listRel="urn:relationships_2014_1.lists.webservices.netsuite.com" xsi:type="listRel:Customer"  xmlns:platformMsgs="urn:messages_2014_1.platform.webservices.netsuite.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
		<listRel:entityId>Alex De Silva</listRel:entityId>
		<listRel:companyName>Company, Inc</listRel:companyName>
		<listRel:subsidiary>
		<RecordRef:internalId>3</RecordRef:internalId>
		<RecordRef:type>subsidiary</RecordRef:type>
		</listRel:subsidiary>
	  </platformMsgs:record>
    </urn:records>
  </soapenv:Body>
</soapenv:Envelope> 

Attaching a file or record

The attach operation can be used to define a relationship between two records. For example, a Contact record can be associated with a Partner record, or an Opportunity record can be associated with a Customer record. A user error is thrown if you attempt to attach files or records that do not exist.

You can also use the attach operations to attach a file to a record. Any file that is in the NetSuite file cabinet (such as a Microsoft Word or Excel file or a PDF) can be attached to any record other than a custom record.

  • When attaching Contacts to other entity records, the Contact's role can also be specified during the request. Contact Roles are roles available in a user defined list at List > Relationships > Contacts. This list is exposed as ContactRole in accounting.xsd.

  • Contact records can be attached to all entity records except for other Contact or Group records.

attach
<netsuite.attach>
	<attachReferece>{$ctx:attachReferece}</attachReferece>
</netsuite.attach>
Properties
  • attachReference: The reference object of the record that needs to be attached.

Sample request

Following is a sample SOAP request that can be handled by the attach operation.

Sample Request for attach
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="wso2.connector.netsuite.attach">
  <soapenv:Header></soapenv:Header>
  <soapenv:Body>
 	<urn:apiUrl>https://webservices.na1.netsuite.com/services/NetSuitePort_2014_1</urn:apiUrl>
    <urn:warningAsError></urn:warningAsError>
    <urn:disableMandatoryCustomFieldValidation></urn:disableMandatoryCustomFieldValidation>
    <urn:disableSystemNotesForCustomFields></urn:disableSystemNotesForCustomFields>
    <urn:ignoreReadOnlyFields></urn:ignoreReadOnlyFields>
    <urn:partnerId></urn:partnerId>
    <urn:applicationId></urn:applicationId>
    <urn:email>user@gmail.com</urn:email>
    <urn:password>123</urn:password>
    <urn:account>TVTDRV1193710</urn:account>
    <urn:roleInternalId></urn:roleInternalId>
    <urn:roleExternalId></urn:roleExternalId>
    <urn:roleType></urn:roleType>
    <urn:roleName></urn:roleName>
    <urn:attachReferece>
         <attachReferece xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:AttachContactReference" xmlns:ns1="urn:core_2014_1.platform.webservices.netsuite.com">
            <ns1:attachTo internalId="1251" type="customer" xsi:type="ns1:RecordRef">     
        <ns1:name xsi:type="xsd:string">Acera</ns1:name>    
          </ns1:attachTo>  
            <ns1:contact internalId="961" xsi:type="ns1:RecordRef"/>    
         <ns1:contactRole internalId="-10" xsi:type="ns1:RecordRef">     
            <ns1:name xsi:type="xsd:string">Primary Contact</ns1:name>    
          </ns1:contactRole> 
         </attachReferece>
      </urn:attachReferece>
  </soapenv:Body>
</soapenv:Envelope> 

 Initializing a list

The initializeList operation can be used to emulate the UI workflow by pre-populating fields on transaction line items with values from a related record. Your Web services application can then modify only the values it needs to before submitting the record.

For example, in the UI, clicking Bill from a Sales Order record loads an Invoice record where fields are populated with values from the Sales Order. When loading an invoice record in Web services, you can reference the related Sales Order record to initialize fields with values from that sales order.

  • To submit an initialized record without having to remove read-only fields populated during the initialization, set the Ignore Read-Only header preference to TRUE.
  • When this preference is set to TRUE, read-only fields are simply ignored during the Web services request. The fields still cannot be set.
initializeList
<netsuite.initializeList>
	 <initializeRecords>{$ctx:initializeRecords}</initializeRecords>
</netsuite.initializeList> 
Properties
  • warningAsError: A boolean Preference object element value specifying whether to treat warnings as errors.
  • disableSystemNotesForCustomFields: A boolean Preference object element value specifying whether to disable system notes for custom fields.
  • ignoreReadOnlyFields: A boolean Preference object element value specifying whether to ignore read-only fields.
  • disableMandatoryCustomFieldValidation: A boolean Preference object element value specifying whether to perform mandatory custom field validation.
  • initializeRecords: One or more initializeRecord details. The InitializeRecord type takes the following fields: typereferenceauxReferencereferenceList

Sample request

Following is a sample SOAP request that can be handled by the initializeList operation.

Sample Request for initializeList
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="wso2.connector.netsuite.initializelist">
   <soapenv:Header/>
   <soapenv:Body>
    	<urn:apiUrl>https://webservices.na1.netsuite.com/services/NetSuitePort_2014_1</urn:apiUrl>
    	<urn:warningAsError></urn:warningAsError>
    	<urn:disableMandatoryCustomFieldValidation></urn:disableMandatoryCustomFieldValidation>
   		<urn:disableSystemNotesForCustomFields></urn:disableSystemNotesForCustomFields>
    	<urn:ignoreReadOnlyFields></urn:ignoreReadOnlyFields>
    	<urn:partnerId></urn:partnerId>
    	<urn:applicationId></urn:applicationId>
    	<urn:email>user@gmail.com</urn:email>
    	<urn:password>123</urn:password>
    	<urn:account>TVTDRV1193710</urn:account>
    	<urn:roleInternalId></urn:roleInternalId>
    	<urn:roleExternalId></urn:roleExternalId>
    	<urn:roleType></urn:roleType>
    	<urn:roleName></urn:roleName>
      	<urn:initializeRecords>
         	<platformMsgs:initializeRecord xmlns:platformMsgs="urn:messages_2014_1.platform.webservices.netsuite.com" xmlns:platformCore="urn:core_2014_1.platform.webservices.netsuite.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <platformCore:type>customerPayment</platformCore:type>
            <platformCore:reference type="customer" internalId="3752" externalId=""/>
         </platformMsgs:initializeRecord>
        </urn:initializeRecords>
   </soapenv:Body>
</soapenv:Envelope> 

Sample configuration

Following is a sample proxy service that illustrates how to connect to NetSuite with the init operation and use the addList operation. The sample request for this proxy can be found in addList sample request. You can use this sample as a template for using other operations in this category.

Sample Proxy
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="netsuite_addList"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property xmlns:ns="wso2.connector.netsuite.addlist"
                   name="apiUrl"
                   expression="//ns:apiUrl/text()"/>
         <property xmlns:ns="wso2.connector.netsuite.addlist"
                   name="warningAsError"
                   expression="//ns:warningAsError/text()"/>
         <property xmlns:ns="wso2.connector.netsuite.addlist"
                   name="disableMandatoryCustomFieldValidation"
                   expression="//ns:disableMandatoryCustomFieldValidation/text()"/>
         <property xmlns:ns="wso2.connector.netsuite.addlist"
                   name="disableSystemNotesForCustomFields"
                   expression="//ns:disableSystemNotesForCustomFields/text()"/>
         <property xmlns:ns="wso2.connector.netsuite.addlist"
                   name="ignoreReadOnlyFields"
                   expression="//ns:ignoreReadOnlyFields/text()"/>
         <property xmlns:ns="wso2.connector.netsuite.addlist"
                   name="partnerId"
                   expression="//ns:partnerId/text()"/>
         <property xmlns:ns="wso2.connector.netsuite.addlist"
                   name="applicationId"
                   expression="//ns:applicationId/text()"/>
         <property xmlns:ns="wso2.connector.netsuite.addlist"
                   name="email"
                   expression="//ns:email/text()"/>
         <property xmlns:ns="wso2.connector.netsuite.addlist"
                   name="password"
                   expression="//ns:password/text()"/>
         <property xmlns:ns="wso2.connector.netsuite.addlist"
                   name="account"
                   expression="//ns:account/text()"/>
         <property xmlns:ns="wso2.connector.netsuite.addlist"
                   name="roleInternalId"
                   expression="//ns:roleInternalId/text()"/>
         <property xmlns:ns="wso2.connector.netsuite.addlist"
                   name="roleExternalId"
                   expression="//ns:roleExternalId/text()"/>
         <property xmlns:ns="wso2.connector.netsuite.addlist"
                   name="roleType"
                   expression="//ns:roleType/text()"/>
         <property xmlns:ns="wso2.connector.netsuite.addlist"
                   name="roleName"
                   expression="//ns:roleName/text()"/>
         <property xmlns:ns="wso2.connector.netsuite.addlist"
                   name="records"
                   expression="//ns:records/*"/>
         <netsuite.init>
            <apiUrl>{$ctx:apiUrl}</apiUrl>
            <warningAsError>{$ctx:warningAsError}</warningAsError>
            <disableSystemNotesForCustomFields>{$ctx:disableSystemNotesForCustomFields}</disableSystemNotesForCustomFields>
            <ignoreReadOnlyFields>{$ctx:ignoreReadOnlyFields}</ignoreReadOnlyFields>
            <disableMandatoryCustomFieldValidation>
            {$ctx:disableMandatoryCustomFieldValidation}
            </disableMandatoryCustomFieldValidation>			
            <roleInternalId>{$ctx:roleInternalId}</roleInternalId>
            <partnerId>{$ctx:partnerId}</partnerId>
            <applicationId>{$ctx:applicationId}</applicationId>
            <roleName>{$ctx:roleName}</roleName>
            <password>{$ctx:password}</password>
            <roleExternalId>{$ctx:roleExternalId}</roleExternalId>
            <email>{$ctx:email}</email>
            <account>{$ctx:account}</account>
            <roleType>{$ctx:roleType}</roleType>
         </netsuite.init>
         <netsuite.addList>
            <records>{$ctx:records}</records>
         </netsuite.addList>
         <respond/>
      </inSequence>
      <outSequence>
        <send/>
      </outSequence>
   </target>
   <description/>
</proxy>