Contact Free trial Login

NetSuite OpenAir Connector - Mule 4

Support Category: Select

NetSuite OpenAir Connector v2.0

Anypoint Connector for NetSuite OpenAir (NetSuite OpenAir Connector) is a closed-source enterprise connector that provides a connection between OpenAir and third-party software.

Prerequisites

To use this information, you must be familiar with NetSuite OpenAir, Mule runtime engine (Mule), Anypoint Connectors, Anypoint Studio, Mule concepts, elements in a Mule flow, and Global Elements.

To use this connector, you need:

  • A NetSuite OpenAir instance

  • A set of valid credentials, including username, password, companyID, API namespace, and key.

  • A MuleSoft Enterprise License

OpenAir complex types are limited to a set of OpenAir operations. See the OpenAir documentation for information about its object types. For example, object oaActualCost works with read, add, modify, and upsert methods, while object oaApproval works only with the submit method.

POM File Information

<dependency>
  <groupId>com.mulesoft.connectors</groupId>
  <artifactId>mule-netsuite-openair-connector</artifactId>
  <version>RELEASE</version>
  <classifier>mule-plugin</classifier>
</dependency>

Mule converts RELEASE to the latest version. To specify a version, view NetSuite OpenAir Connector in Anypoint Exchange and click Dependency Snippets.

Compatibility

The OpenAir connector is compatible with:

Application/Service Version

Mule

EE 4.1.0 and later

Anypoint Studio

7.1 and later

Java

JDK 8

Connect in Flow Designer

Flow Designer provides input sources (known as triggers) for:

  • On New Object - Start your application when a NetSuite user creates an object.

  • On Modified Object - Start your application when a NetSuite user modifies an object.

  • On Deleted Object - Start your application when a NetSuite user deletes an object.

  • HTTP Listener - Start your application from a browser, curl, or Postman.

  • Scheduler - Start your application at selected time intervals.

To configure your Flow Designer app:

  1. Configure a trigger.

  2. Select the plus sign next to the trigger to add a component.

  3. Select the connector as a component.

  4. Select the operation:

    operations
  5. Configure the Global Element for the connector:

    account config
    Field Description

    Company

    Enter the company.

    Username

    Enter the user name to connect to.

    Password

    Enter the password for the user.

    API Namespace

    Enter the API namespace.

    Api Key

    Enter the API key.

  6. Optionally configure the connection options for the connector:

    connector config
    Field Description

    Endpoint

    Enter the endpoint.

    Connection Timeout

    Enter the connection timeout.

    Read Timeout

    Enter the read timeout.

Add the Connector to Your Project

Anypoint Studio provides two ways to add the connector to your Studio project: from the Exchange button in the Studio taskbar or from the Mule Palette view.

Add the Connector Using Exchange

  1. In Studio, create a Mule project.

  2. Click the Exchange icon (X) in the upper-left of the Studio task bar.

  3. In Exchange, click Login and supply your Anypoint Platform username and password.

  4. In Exchange, search for "openair".

  5. Select the connector and click Add to project.

  6. Follow the prompts to install the connector.

Add the Connector in Studio

  1. In Studio, create a Mule project.

  2. In the Mule Palette view, click (X) Search in Exchange.

  3. In Add Modules to Project, type "openair" in the search field.

  4. Click this connector’s name in Available modules.

  5. Click Add.

  6. Click Finish.

Configure in Studio

  1. Drag the connector operation to the Studio Canvas (they are the same as are in Design Center).

  2. Configure the Global Element for the connector:

    anypoint config
  3. If needed, configure a connection:

    anypoint connection
    1. Enable the automatic reconnection feature.

    2. Access the OpenAir Global Element configuration window from Studio.

    3. Click the Advanced tab (next to Connection).

    4. Select the Standard option in Reconnection Strategy.

    5. Adjust the Frequency (ms) and Reconnection Attempts fields accordingly.

Log HTTP Requests and Responses

To log the HTTP interactions of the connector with NetSuite OpenAir, configure the log4j2.xml file for the Mule app as follows, and use a Logger component in your project to display the results:

<AsyncLogger name="org.mule.service.http" level="DEBUG"/>

Use Case: Add OpenAir Object

OpenAir use case flow
  1. In Studio, drag an HTTP Listener operation onto the canvas and configure it to listen to host 0.0.0.0 at port 8081.

  2. Drag the OpenAir Add operation connector into the flow and configure the connector as described in Configure in Studio.

  3. Drag a Transform Message component between the HTTP connector and the OpenAir connector.

  4. In the Transform Message component, insert the DataWeave script into the DataWeave editor to add oaCustomer objects to your NetSuite OpenAir instance:

    %dw 2.0
    output application/xml
    ns ns0 http://namespaces.soaplite.com/perl
    ---
    {
      ArrayOfoaBase: {
        oaBase: {
          ns0#oaCustomer: {
            name: "James Bond",
                  company: "MuleSoft"
          },
          ns0#oaCustomer: {
            name: "Jane Doe",
            company: "Salesforce"
          }
        }
      }
    }
  5. Drag another Transform Message component after the OpenAir connector, and insert the DataWeave script into the Transform Message component’s DataWeave editor.

    The script should return the IDs of the newly added OpenAir objects.

    %dw 2.0
    output application/json
    ns ns0 http://namespaces.soaplite.com/perl
    ---
    {
    	customerName_1: payload.ns0#ArrayOfUpdateResult.*updateResult[0].id,
    	customerName_2: payload.ns0#ArrayOfUpdateResult.*updateResult[1].id
    }
  6. Save the project.

  7. In Package Explorer, right-click the project and click Run As > Mule Application.

  8. Use a browser to access http://0.0.0.0:8081, and the following JSON displays:

    {
        "customerName_1": "411",
        "customerName_2": "412"
    }

Use Case: XML

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:openair="http://www.mulesoft.org/schema/mule/openair"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/openair
http://www.mulesoft.org/schema/mule/openair/current/mule-openair.xsd
http://www.mulesoft.org/schema/mule/ee/core
http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
   <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config">
      <http:listener-connection host="0.0.0.0" port="8081" />
   </http:listener-config>
   <openair:config name="Open_Air_Config" doc:name="Open Air Config">
      <openair:login-authentication-connection
      company="${config.company}"
      username="${config.username}"
      password="${config.company}"
      apiNamespace="${config.namespace}"
      apiKey="${config.key}"
      endpoint="${config.endpoint}"
      connectionTimeout="${config.conTimeout}"
      readTimeout="${config.readTimeout}" />
   </openair:config>
   <flow name="testopenairFlow">
      <http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/" />
      <ee:transform doc:name="Transform Message">
         <ee:message>
            <ee:set-payload><![CDATA[%dw 2.0 output application/xml ns ns0 http://namespaces.soaplite.com/perl  --- { ns0#ArrayOfoaBase: { oaBase: { oaCustomer: { name: "James Bond", company: "MuleSoft" }, oaCustomer: { name: "Jane Doe", company: "Salesforce" } } } }]]></ee:set-payload>
         </ee:message>
      </ee:transform>
      <openair:add doc:name="Add" config-ref="Open_Air_Config" oaObject="jasdhjasdhik" />
      <ee:transform doc:name="Transform Message">
         <ee:message>
            <ee:set-payload><![CDATA[%dw 2.0 output application/json ns ns0 http://namespaces.soaplite.com/perl --- { ID1: payload.ns0#ArrayOfUpdateResult.*updateResult[0].id, ID2: payload.ns0#ArrayOfUpdateResult.*updateResult[1].id }]]></ee:set-payload>
         </ee:message>
      </ee:transform>
   </flow>
</mule>