Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

NetSuite Connector

*Standard *

Anypoint Connector for NetSuite synchronizes data and automates business processes between NetSuite and third party applications, either on-premises or in the cloud.

Prerequisites

This document assumes that you are familiar with Mule, Anypoint Connectors, and the Anypoint Studio interface. To increase your familiarity with Studio, consider completing one or more Anypoint Studio Tutorials. Further, this page assumes that you have a basic understanding of Mule flows and Mule Global Elements

This document describes implementation examples within the context of Anypoint Studio, Mule ESB’s graphical user interface, and, also includes configuration details for doing the same in the XML Editor.

Installing the NetSuite Connector in Anypoint Studio

You can install a connector in Anypoint Studio using the instructions in To Install a Connector from Anypoint Exchange.

Configuring the NetSuite Connector

To use the NetSuite connector, you must configure:

  • A global NetSuite element for use by all the NetSuite connectors in an application.

  • Parameters of each NetSuite connector instance in the application.

Follow these steps to configure NetSuite connector in a Mule application:

Studio Visual Editor

  1. Click the Global Elements tab at the base of the canvas, then click Create.

  2. In the Choose Global Type menu, use the filter to locate and select NetSuite, then click OK.

  3. Configure the parameters according to the table below

    Parameter Description

    Name

    Enter a name for the configuration so it can be referenced later.

    Email

    Enter the login email of the NetSuite UI.

    Password

    Enter the corresponding password to log into NetSuite UI.

    Endpoint

    Enter the name of the service endpoint.

    Ensure that the endpoint you enter here points to the version of NetSuite that the connector supports. 

    Account

    Enter the account ID of the SuiteTalk - NetSuite web services. It looks similar to TSTDRVXXXXXX.

    RoleId

    Enter the role ID for the user in SuiteTalk, which determines the Processor privileges.

    Connection Timeout

    Enter the amount of time, in milliseconds, that the client must attempt to establish a connection before timing out. The default is 30000 (30 seconds). Zero (0) indicates that the client continues to attempt to open a connection indefinitely.

    Receive Timeout

    Enter the amount of time, in milliseconds, that the client must wait for a response before timing out. The default is 60000. Zero (0) specifies that the client waits indefinitely.

    Enable DataSense

    If you select this option, DataSense extracts metadata for NetSuite standard objects to automatically determine the data type and format that your application must deliver to, or can expect from, NetSuite. By enabling this functionality, Mule does the heavy lifting of discovering the type of data you must send to, or be prepared to receive from NetSuite. For more information, see DataSense.

    Default Endpoint

    Enter the default service endpoint.

    Separator

    Enter the separator used to support the keys that are required to provide a better support for custom fields. 

  4. Access the Pooling Profile tab to configure any settings relevant to managing multiple connections via a connection pool.

  5. Access the Reconnection tab to configure any settings relevant to reconnection strategies that Mule should execute if it loses its connection to NetSuite.

  6. Click OK to save the global connector configurations.

  7. Return to the Message Flow tab in Studio.

Configuration in a Flow

Follow these steps to configure the parameters of the NetSuite connector in the flow:

  1. Drag the NetSuite connector onto the canvas, and double-click it to open the Properties Editor console.

  2. Configure these parameters for the connector:

    Field Description Default

    Display Name

    Enter a unique label for the connector in your application.

    Netsuite

    Config Reference

    Connect to a global element linked to this connector. Global elements encapsulate reusable data about the connection to the target resource or service. Select the global NetSuite connector element that you just created.

     — 

    Operation

    Select the action this component must perform.

     — 

  3. Save your configurations.

[tab,title="XML Editor"]

Ensure that you include the NetSuite namespaces in your configuration file.


           
        
1
2
3
4
5
6
7
8
9
10
11
12
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:netsuite="http://www.mulesoft.org/schema/mule/netsuite"
      xsi:schemaLocation="
               http://www.mulesoft.org/schema/mule/core
               http://www.mulesoft.org/schema/mule/core/current/mule.xsd
               http://www.mulesoft.org/schema/mule/netsuite
               http://www.mulesoft.org/schema/mule/netsuite/current/mule-netsuite.xsd">
 
      <!-- Your flows and configuration elements -->
 
</mule>

Follow these steps to configure a NetSuite connector in your application:

  1. Create a global NetSuite configuration outside and above your flows, using the following global configuration code:

    
                  
               
    1
    2
    
    <!-- Simple configuration -->
    <netsuite:config name="Netsuite" email="Your NetSuite email" password="Your NetSuite password" account="Your Netsuite account name" roleId="The id of your NetSuite role" doc:name="Netsuite">
  2. Build your application flow, then add a NetSuite connector using one of these operations:  

    Operation Description

    <netsuite:add-file>

    Creates a new NetSuite file record.

    <netsuite:add-list>

    Adds one or more records in the system.

    The attributes that define each record can either be the POJOs corresponding to the fields in the record or a map that represents it.

    <netsuite:add-record>

    Creates a new record of the specified type.

    <netsuite:add-record-objects>

    Creates new records of the specified type.

    <netsuite:async-add-list>

    Specifies an asynchronous request equivalent to `addRecord(String, Map, Preferences) `

    <netsuite:async-delete-list>

    Specifies an asynchronous request equivalent to `deleteList(List, Preferences) `

    <netsuite:async-delete-list-records>

    Specifies an asynchronous request equivalent to `deleteList(List, Preferences) `

    <netsuite:async-get-list>

    Specifies an asynchronous request equivalent to `getList(List, Preferences) `

    <netsuite:async-get-list-records>

    Specifies an asynchronous request equivalent to `getList(List, Preferences) `

    <netsuite:async-initialize-list>

    Specifies an asynchronous request equivalent to `initialize(InitializeRecord, Preferences) `

    <netsuite:async-search>

    Searches for all records that match the given filtering expression, asynchronously.

    <netsuite:async-update-list>

    Specifies an asynchronous request equivalent to `updateRecord(String, Map, Preferences) `

    <netsuite:async-upsert-list>

    Specifies an asynchronous request equivalent to `upsertRecord(String, Map, Preferences) `

    <netsuite:attach-record>

    Adds a source contact record to a destination record as an attachment.

    <netsuite:change-email>

    Changes the email address for the NetSuite account.

    <netsuite:change-password>s

    Changes the password for the NetSuite account.

    <netsuite:check-async-status>

    Returns the status of an asynchronous web services submission.

    <netsuite:delete>

    Deletes a record with the specified BaseRef.

    Not all records can be deleted from the system.

    <netsuite:delete-list>

    Deletes one or more records in the system. The records to be deleted are identified through the specified unique identifiers.

    <netsuite:delete-record>

    Deletes a record from the system with the specified RecordRef.

    Not all records can be deleted from the system.

    <netsuite:delete-records-list>

    Deletes one or more records from the system. The records to be deleted are identified through the provided unique identifiers.

    <netsuite:detach-record>

    Detaches a source record from a destination record.

    <netsuite:get>

    Retrieves a record by providing the unique ID for the record.

    <netsuite:get-async-result>

    Returns the results of an asynchronous web services submission.

    <netsuite:get-budget-exchange-rates>

    Returns the list of budget exchange rates.

    <netsuite:get-consolidated-exchange-rates>

    Returns the list of consolidated exchange rates.

    <netsuite:get-current-rate>

    Gets the exchange rate between two currencies based on a certain date.

    <netsuite:get-custom-record>

    Retrieves a custom record by providing the unique ID for the record.

    <netsuite:get-customization-ids>

    Returns the IDs of available customizations for a given record type.

    <netsuite:get-data-center-urls>

    Gets datacenter URLS - use for dynamic discovery of datacenter-specific URLs to access NetSuite as partner applications.

    <netsuite:get-deleted-records>

    Returns a list of deleted records of the specified record type that match a given date expression.

    <netsuite:get-item-availability>

    Returns the availability of a given record reference.

    <netsuite:get-list>]

    Retrieves a list of objects referenced in the list of BaseRef object.

    <netsuite:get-posting-transaction-summary>

    Retrieves a summary of the actual data in an account.

    <netsuite:get-record>

    Retrieves a record by providing the unique ID for the record.

    <netsuite:get-records>

    Retrieves a list of all records of the specified type.

    <netsuite:get-saved-search>

    Retrieves a list of existing saved searches for the given record type.

    <netsuite:get-select-value>

    Retrieves valid values for a given recordRef field where the referenced record type is not yet exposed in the web services API or when the logged in role does not have permission to the instances of the record type.

    <netsuite:get-server-time>

    Returns the server time, resulting in more accurate and reliable synchronization of data than using local client time.

    <netsuite:initialize>

    Populates fields on transaction line items with values from a related record in a way similar to how empty text boxes are pre-populated within the Netsuite UI.

    <netsuite:initialize-list>

    Emulates the UI workflow by pre-populating fields on transaction line items with values from a related record.

    <netsuite:map-sso>

    Automates the mapping between external application credentials and NetSuite’s credentials for a user.

    <netsuite:query-as-native-result>

    Returns a SearchResult containing a list of records or columns matching the specified query.

    <netsuite:query-records>

    Returns a list of records.

    <netsuite:search>

    Executes a search on a specific record type based on a set of criteria.

    <netsuite:search-more>

    Retrieves more records after an initial search operation.

    <netsuite:search-more-with-id>

    References a specific search result set by its searchId - a parameter included in all search results.

    <netsuite:search-next>

    Retrieves the next set of records after an initial search operation.

    <netsuite:search-with-expression>

    Executes a search on a specific record type based on a set of criteria.

    <netsuite:sso-login>

    Establishes a single sign-on connection.

    <netsuite:update-invitee-status>

    Sets a new invitation status for a given event.

    <netsuite:update-invitee-status-list>

    Sets a new invitation status for a given event.

    <netsuite:update-list>

    Updates one or more existing records in the system by providing new values for some fields in the records.

    <netsuite:update-record>

    Updates an existing record.

    <netsuite:update-records-list>

    Updates one or more existing records in the system by providing a list of records.

    <netsuite:upsert-list>

    Updates one or more instances of a record type in the system.

    <netsuite:upsert-record>

    Adds a new instance or updates an instance of a record in the system.

------

== Example Use Case

Add a new Employee record in NetSuite using a Mule application. 

image:NetSuiteDemoFlow.png[NetSuiteDemoFlow]

. Drag an *HTTP* connector into a new flow, click the green plus to the right of Connector Configuration and set the values to: Host: *localhost* and Port: **8081**. Click *OK*. In the Basic Settings, set the *Path* to *accountWithCustomFields*.

+
image:HTTPSettings.png[HTTPSettings]
+

. Add a *Set Payload* transformer after the HTTP connector to process the message payload. Configure the transformer as shown below.
+
image:setpayload.jpg[setpayload]
+

[%header%autowidth.spread]
|===
|Field |Value
|*Display Name* |Set Payload (or any other name you prefer)
|*Value* |`# [['name':message.inboundProperties['name'],'lastname':message.inboundProperties['lastname'],'e-mail':message.inboundProperties['email'],'externalId':message.inboundProperties['externalId']]]`
|===
+

. Drag the *NetSuite* connector onto the canvas, then select it to open the properties editor console.
. Click the plus sign next to the *Connector Configuration* field to add a new NetSuite global element.
+
image:global+element.jpg[global+element]
+
. Configure the global element as follows:
+
[%header%autowidth.spread]
|===
|Field |Value
|*Name* |NetSuite (or any other name you prefer)
|*Email* |<Your NetSuite Email>
|*Password* |<Your NetSuite password>
|*Account* |<Your NetSuite account> (It looks similiar to TSTDRVXXXXXX.)
|*Role Id* |Enter the id of the role you use to login in SuiteTalk, which determines the Processor privileges.
|===
+
. In the properties editor of the NetSuite connector, configure the remaining parameters:
+
image:Configuration.jpg[Configuration]
+
[%header%autowidth.spread]
|===
|Field |Value
|*Display Name* |NetSuite (or any other name you prefer)
|*Config Reference* |NetSuite (name of the global element you have created)
|*Operation* |Add record
|*Record Type* |Employee
|===
+
. Drag a *DataMapper* transformer between the Set Payload transformer and the NetSuite connector, then click it to open its properties editor.
. Configure its Input properties according to the steps below. +
.. In the *Input type*, select **Map<k,v>**, then select *User Defined*.
.. Click **Create/Edit Structure**.  
.. Enter a name for the Map, then select *Element* for** Type**.
.. Add the child fields according to the table below.
+
[%header,cols="2*"]
|===
a|
Name

 a|
Type

|*e-mail* |String
|*externalId* |String
|*lastname* |String
|*name* |String
|===
+
.. The Output properties are automatically configured to correspond to the NetSuite connector.
.. Click *Create Mapping*, then drag each input data field to its corresponding output NetSuite field. Click the blank space on the canvas to save the changes.
. Add a *Object to Json* transformer onto the flow to capture the response from the NetSuite connector and display it as a HTTP response. 
. Run the project as a Mule Application (right-click project name, then select *Run As > Mule Application* ). 
. From a browser, e nter the employee's e-mail address, externalId, lastname, and name in the form of the following query parameters:**  http://localhost:8081/accountWithCustomFields?** * email  =<employee's email address> &externalId=<employee's externalId> &lname= <employee's last name>&name=<employee's firstname> *
. Mule conducts the query, and adds the Employee record to NetSuite.

=== XML Editor

. Add a *netsuite:config* element to your project, then configure its attributes according to the  table below.
+

[source, xml, linenums]
----
<netsuite:config name="NetSuite" email="email@youremail.com" password="netsuite_password" account="netsuite_account" roleId="netsuite_role" doc:name="Netsuite">
            </netsuite:config>
----

+
[%header%autowidth.spread]
|===
|Attribute |Value
|*name* |NetSuite
|*email* |<Your NetSuite Email>
|*password* |<Your NetSuite password>
|*account* |<Your NetSuite account> (It looks similiar to TSTDRVXXXXXX.)
|*roleId* |Enter the ID of the role you use to login in SuiteTalk, which determines the Processor privileges.
|*doc:name* |NetSuite
|===
.  Create a Mule flow with an HTTP endpoint, configuring the endpoint as follows:  
+

[source, xml, linenums]
----
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="accountWithCustomFields" doc:name="HTTP"/>
----

+
[%header,cols="2*"]
|===
|Attribute |Value
|*exchange-pattern* |request-response
|*host* |localhost
|*port* |8081
|*path* a|`accountWithCustomFields` |*doc:name* |HTTP
|===
. Add a *set-payload* element to set the message payload in the flow.
+

[source, xml, linenums]
----
<set-payload value="#[['name':message.inboundProperties['name'],'lastname':message.inboundProperties['lastname'],'e-mail':message.inboundProperties['email'],'externalId':message.inboundProperties['externalId']]]" doc:name="Set Payload"/>
----

. Add a **data-mapper** element to pass the message payload to NetSuite.
+

[source, xml, linenums]
----
<data-mapper:transform config-ref="Map_To_EMPLOYEE" doc:name="Map To EMPLOYEE"/>
----

. Add a *netsuite:add-record* element to your flow as follows:
+

[source, xml, linenums]
----
<netsuite:add-record config-ref="Netsuite" doc:name="Netsuite Add Record" recordType="EMPLOYEE"/>
----

. Configure the data-mapper through the Visual Editor. Switch the view to Message Flow view, then click the *DataMapper* transformer to set its properties.
.. In the *Input type*, select **Map<k,v>**, then select *User Defined*.
.. Click **Create/Edit Structure**.  
.. Enter a name for the Map, then select *Element* for** Type**.
.. Add the child fields according to the table below.
+
[%header,cols="2*"]
|===
a|
Name

 a|
Type

|*e-mail* |String
|*externalId* |String
|*lastname* |String
|*name* |String
|===
. Add a *json:object-to-json-transformer* element to the flow to capture the response from the NetSuite connector and display it as an HTTP response. 
+

[source, xml, linenums]
----
<json:object-to-json-transformer doc:name="Object to JSON"/>
----

. Run the project as a Mule Application (right-click project name, then select **Run As > Mule Application**). 
. From a browser, e nter the employee's e-mail address, externalId, lastname, and name in the form of the following query parameters:**  http://localhost:8081/accountWithCustomFields ?** * email =<employee's email address> &externalId=<employee's externalId> &lname= <employee's last name>&name=<employee's firstname> *
. Mule conducts the query, and adds the Employee record to NetSuite.
Example Code

[NOTE]
====
Keep in mind that for this example code to work, you must manually configure the following values of the *global NetSuite connector* to match your instance of NetSuite:

* Email
* Password
* Account
* Role ID
====

[source, xml, linenums]
----
<mule xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:netsuite="http://www.mulesoft.org/schema/mule/netsuite"
    xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/netsuite http://www.mulesoft.org/schema/mule/netsuite/current/mule-netsuite.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
    <netsuite:config name="Netsuite" email="${email}"
        password="${password}" account="${account}" connectionTimeout="50000"
        receiveTimeout="50000" doc:name="Netsuite" roleId="${RoleID}">
        <netsuite:connection-pooling-profile
            initialisationPolicy="INITIALISE_ONE" exhaustedAction="WHEN_EXHAUSTED_GROW" />
    </netsuite:config>
    <data-mapper:config name="JSON_To___customRecordType__21____customrecord21" transformationGraphPath="json_to___customrecordtype__21____customrecord21.grf" doc:name="JSON_To___customRecordType__21____customrecord21"/>
    <data-mapper:config name="Map_To_EMPLOYEE" transformationGraphPath="map_to_employee.grf" doc:name="Map_To_EMPLOYEE"/>
    <http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
    <http:listener-config name="HTTP_Listener_Configuration1" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
    <flow name="netsuite-demoFlow1" >
    <http:listener config-ref="HTTP_Listener_Configuration" path="accountWithCustomFields" doc:name="HTTP"/>
    <set-payload value="#[['name':message.inboundProperties['name'],'lastname':message.inboundProperties['lastname'],'e-mail':message.inboundProperties['email'],'externalId':message.inboundProperties['externalId']]]" doc:name="Set Payload"/>
    <data-mapper:transform config-ref="Map_To_EMPLOYEE" doc:name="Map To EMPLOYEE"/>
        <netsuite:add-record
            config-ref="Netsuite" doc:name="Netsuite Add Record" recordType="EMPLOYEE"/>
        <json:object-to-json-transformer doc:name="Object to JSON"/>
    </flow>
  <flow name="netsuite-demoFlow2" >
    <http:listener config-ref="HTTP_Listener_Configuration1" path="customRecord" doc:name="HTTP"/>
    <data-mapper:transform config-ref="JSON_To___customRecordType__21____customrecord21" doc:name="JSON To __customRecordType__21____customrecord21"/>
    <netsuite:add-record config-ref="Netsuite" recordType="__customRecordType__21____customrecord21" doc:name="Netsuite"/>
    <json:object-to-json-transformer doc:name="Object to JSON"/>
  </flow>
</mule>
----