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-premise or in the cloud.

Assumptions

This document assumes that you are familiar with Mule, [Anypoin™ 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 "test drive" the NetSuite connector by installing it in Anypoint Studio. Follow the instructions to [download and launch Anypoint Studio], then follow the steps below to install the NetSuite connector.

To install the NetSuite connector in Anypoint Studio:

  1. Under the Help menu in Anypoint Studio, select Install New Software.

    Install

  2. On the Install wizard, click the drop-down arrow for the Work with: field, the select the Anypoint Connector update site

    workwith

  3. In the table below the Filter field, click to expand the Standard folder, and click the check box for NetSuite Connector (Mule 3.5+). Click *Next.

    SelectNetSuite

  4. In the Install Details, click Next.

  5. In Review Licenses, review the license text, and click I accept the terms of the license agreement. Click Finish. The connector installs.

  6. At the end of the installation, click Yes to restart Anypoint Studio. After Anypoint Studio restarts, the NetSuite connector appears in the list of connectors.

    connectorslist

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. For more information, see [Mule Global Elements].

  • Parameters of each NetSuite connector instance in the application.

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

  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.

    Configuration

    Parameter Description

    Name

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

    Email

    Enter a login email of the NetSuite UI.

    Password

    Enter the corresponding password to log into NetSuite UI.

    Endpoint

    Enter the name of the service endpoint.

    Please 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.

    Seperator

    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 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

    -

    Refer to the list of supported operations and their descriptions on the XML Editor tab.
  3. Click the black space on the canvas to save your configuration

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">
  1. Build you 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>

    pecifies 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>

    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.

Flow

  1. Drag an HTTP Endpoint into a new flow, and configure it as follows:

    http

    Field Value

    Display Name

    HTTP (or any other name your prefer)

    Exchange Pattern

    request-response

    Host

    localhost

    Port

    8081

    Path

    accountWithCustomFields

  2. Add a Set Payload transformer after HTTP endpoint to process the message payload. Configure the transformer as shown below.

    setpayload

    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']]]

  3. Drag the NetSuite connector onto the canvas, then select it to open the properties editor console.

  4. Click the + sign next to the Connector Configuration field to add a new NetSuite global element.

    global+element

  5. Configure the global element as follows:

    Field Value

    Name

    NetSuite (or any other name you prefer)

    Email

    <Your NetSuite Email>

    Password

    <Your NetSuite password>

    Account

    <Your NetSuite account> (It looks similar to TSTDRVXXXXXX.)

    Role Id

    Enter the id of the role you use to login in SuiteTalk, which determines the Processor privileges.

  6. In the properties editor of the NetSuite connector, configure the remaining parameters

    Configuration

    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

  7. Drag a DataMapper transformer between the Set Payload transformer and the NetSuite connector, then click it to open its properties editor.

  8. Configure its Input properties according to the steps below.

    1. In the Input type, select Map<k,v>, then select User Defined.

    2. Click Create/Edit Structure.

    3. Enter a name for the Map, then select Element for Type.

    4. Add the child fields according to the table below.

      Name Type

      e-mail

      String

      externalid

      String

      lastname

      String

      name

      String

    5. The Output properties are automatically configured to correspond to the NetSuite connector.

    6. 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.

  9. Add a Object to Json transformer onto the flow to capture the response from the NetSuite connector and display it as a HTTP response.

  10. Run the project as a Mule Application (right-click project name, then select Run As > Mule Application).

  11. From a browser, enter 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>

  12. Mule conducts the query, and adds the Employee record to NetSuite.

Flow

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

    
           
                   
                
    1
    2
    
    &lt;netsuite:config name="NetSuite" email="email@youremail.com" password="netsuite_password" account="netsuite_account" roleId="netsuite_role" doc:name="Netsuite"&gt;
                &lt;/netsuite:config&gt;
    Attribute Value

    exchange-pattern

    request-response

    host

    localhost

    port

    8081

    path

    accountWithCustomFields

    doc:name

    HTTP

  2. Add a set-payload element to set the message payload in the flow.

    
           
                   
                
    1
    
    &lt;set-payload value="#[['name':message.inboundProperties['name'],'lastname':message.inboundProperties['lastname'],'e-mail':message.inboundProperties['email'],'externalId':message.inboundProperties['externalId']]]" doc:name="Set Payload"/&gt;
  3. Add a data-mapper element to pass the message payload to NetSuite.

    
           
                   
                
    1
    
    &lt;data-mapper:transform config-ref="Map_To_EMPLOYEE" doc:name="Map To EMPLOYEE"/&gt;
  4. Add a netsuite:add-record element to your flow as follows:

    
           
                   
                
    1
    
    &lt;netsuite:add-record config-ref="Netsuite" doc:name="Netsuite Add Record" recordType="EMPLOYEE"/&gt;
  5. Configure the data-mapper through the Visual Editor. Switch the view to Message Flow view, then click the DataMapper transformer to set its properties.

    1. In the Input type, select Map<k,v>, then select User Defined.

    2. Click Create/Edit Structure.

    3. Enter a name for the Map, then select Element for Type.

    4. Add the child fields according to the table below.

      Name Type

      e-mail

      String

      externalid

      String

      lastname

      String

      name

      String

  6. 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.

    
           
                   
                
    1
    
    &lt;json:object-to-json-transformer doc:name="Object to JSON"/&gt;
  7. Run the project as a Mule Application (right-click project name, then select Run As > Mule Application).

  8. From a browser, enter 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>

  9. Mule conducts the query, and adds the Employee record to NetSuite.

Example Code

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


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<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" version="EE-3.5.1"
    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"/>
    <flow name="netsuite-demoFlow1" doc:name="netsuite-demoFlow1">
        <http:inbound-endpoint exchange-pattern="request-response"
            host="localhost" port="8081" doc:name="HTTP" path="accountWithCustomFields"/>
        <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" doc:name="netsuite-demoFlow2">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" 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>