---
schema_version: "1"
id: e06e59eadd9d4347ee71d45e1bc31380a27973a40c5294872b3841b675de6de9
title: NetSuite Connector 11.10 Examples
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/netsuite-connector/11.10/netsuite-examples.md
canonical_url: https://docs.mulesoft.com/netsuite-connector/11.10/netsuite-examples
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 13774d16058ede43ca62b17f0ecb107325092fe24cdd593044df08b7707a1bc5
description: MuleSoft Documentation Site
release: "11.10"
latest: false
---
---
product: NetSuite Connector
version: 11.10
---

# NetSuite Connector 11.10 Examples

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

The following examples show how to perform searches in Anypoint Connector for NetSuite (NetSuite
Connector):

- [Account Basic Search Filtering by an Integer Field](#account-basic-search)

  Obtain the Account records with internal IDs that are less than the value of the `internalId`
  query parameter.

- [Employee Basic Search Filtering by the Boolean and String Fields](#employee-basic-search)

  Obtain the inactive Employee records that have last names beginning with a specified letter.

- [Customer Advanced Search Filtering by the Date and Array Fields](#customer-advanced-search)

  Obtain the customer records that were created after 2015 and that are in the LEAD stage.

The following example shows how to add a file in NetSuite Connector:

- [Add a File](#add-file)

  Add a file using the **Add** operation.

The following example shows how to use custom fields and records in NetSuite Connector:

- [Add a Custom Record](#add-custom-record)

  Add a custom record with custom fields.

- [Get a Custom Record](#get-custom-record)

  Get a custom record with custom fields.

- [Delete a Custom Record](#delete-custom-record)

  Delete a custom record with custom fields.

## Account Basic Search Filtering by an Integer Field

This example shows how to use the NetSuite Connector `Search` operation to obtain the Account
records with internal IDs that are less than the value provided.

This example requires that at least one basic account meets the search condition in the NetSuite
instance.

The following screenshot shows the Studio app flow for this example:

![App flow for the Account basic search example](/mulesoft/current/en-us/netsuite-connector/11.10/_images/netsuite-examples-search-account.png)

Figure 1. Account basic search app flow in Studio

Creating this example involves creating a new Mule project and configuring `HTTP Listener`, the
NetSuite Connector `Search` operation, one `For Each` component, and two `Transform Message`
components.

### Configure HTTP Listener

Configure HTTP Listener to initiate a Mule flow when a call is made to the `/account` path on
localhost port 8081:

1.  Create a new Mule project in Studio.

2.  In Studio, click **HTTP** and drag the **Listener** operation to the canvas.

3.  Change the display name of the **Listener** operation to `/account`.

4.  On the Listener properties window, click **+** next to the **Connector configuration** field to
    add a global element.

5.  Accept the defaults.

6.  On the Listener properties window, set the **Path** field value to `/account`.

### Add the first Transform Message Component

This **Transform Message** component contains the search criteria for the flow:

1.  From the **Mule Palette** view, drag a **Transform Message** component to the right of
    **Listener**.

2.  Change the name of the **Transform Message** component to `Search Criteria`.

3.  Click the **Transform Message** component.

    The **Output** column displays the metadata of the **AccountSearchBasic** object. You can build
    up the criteria from there, or copy the criteria shown below.

    Setting the **searchValue** field to `attributes.queryParams["internalId"]` directs the
    connector to use the value through the query parameter.

    The DataWeave code should look like this:

    ```dataweave
    %dw 2.0
    output application/xml
    ns ns0  urn:messages_2020_2.platform.webservices.netsuite.com
    ns ns01 urn:common_2020_2.platform.webservices.netsuite.com
    ns ns02 urn:core_2020_2.platform.webservices.netsuite.com
    ns xsi http://www.w3.org/2001/XMLSchema-instance
    ---
    {
    	ns0#search: {
    		ns0#searchRecord @("xmlns:ns01": ns01, xsi#"type": "ns01:AccountSearchBasic"): {
    			ns01#internalIdNumber @(operator: "lessThan"): {
    				ns02#searchValue: attributes.queryParams["internalId"]
    			}
    		}
    	}
    }
    ```

### Add the NetSuite Connector Search Operation

1.  From the **Mule Palette** view, select **NetSuite** and drag the **Search** operation to the
    right of **Search Criteria**.

2.  Change the display name of the **Search** operation to `Search Account`.

3.  Select an existing global element or create a new one for the **Search** operation.

4.  On the Search properties window:

    - In the **Key** field, select `AccountSearchBasic`.

    - Set the **Page Size** field value to an integer value between `10` and `1000`.

### Add the For Each Component

From the **Mule Palette** view, select **Core** and drag the **For Each** component to the right of
**Search Account**.

### Add the Second Transform Message Component

This **Transform Message** component converts the response to JSON format:

1.  From the **Mule Palette** view, drag a **Transform Message** component inside the **For Each**
    component.

2.  Change the name of the **Transform Message** component to `Response to JSON`.

3.  Click the **Transform Message** component and set the output to `application/json`.

    ```dataweave
    %dw 2.0
    output application/json
    ns ns0 urn:core_2020_2.platform.webservices.netsuite.com
    ---
    payload.ns0#record
    ```

4.  Drag and drop a **Logger** component from the **Mule Palette** view to the right of **Response
    to JSON**. Leave the message as `#[payload]`

### Run the App

To run the app:

1.  Start the Mule app.

2.  Call `http://localhost:8081/account?internalId=5` to retrieve the `Account` records with
    internal IDs that are less than 5.

3.  You will only be able to see the output from the Mule App console.

### XML for Account Basic Search Flow

Paste this code into a new Mule app in Studio to quickly load the flow for the Account basic search
example. If needed, change the values to reflect your environment.

```xml
<?xml version="1.0" encoding="UTF-8"?>

<mule
    xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
	xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns:netsuite="http://www.mulesoft.org/schema/mule/netsuite" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 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/netsuite http://www.mulesoft.org/schema/mule/netsuite/current/mule-netsuite.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/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>
	<netsuite:config name="tokenConfig" doc:name="NetSuite SOAP Config">
		<netsuite:token-based-authentication-connection consumerKey="${netsuite.consumerKey}" consumerSecret="${netsuite.consumerSecret}" tokenId="${netsuite.tokenId}" tokenSecret="${netsuite.tokenSecret}" account="${netsuite.account}"/>
	</netsuite:config>
	<flow name="account-basic-search-flow">
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="account">
			<http:response statusCode="200" />
		</http:listener>
		<ee:transform doc:name="Search Criteria">
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/xml
ns ns0  urn:messages_2020_2.platform.webservices.netsuite.com
ns ns01 urn:common_2020_2.platform.webservices.netsuite.com
ns ns02 urn:core_2020_2.platform.webservices.netsuite.com
ns xsi http://www.w3.org/2001/XMLSchema-instance
---
{
	ns0#search: {
		ns0#searchRecord @("xmlns:ns01": ns01, xsi#"type": "ns01:AccountSearchBasic"): {
			ns01#internalIdNumber @(operator: "lessThan"): {
				ns02#searchValue: attributes.queryParams["internalId"]
			}
		}
	}
}]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<netsuite:search doc:name="Search Account" config-ref="tokenConfig" key="AccountSearchBasic">
		</netsuite:search>
		<foreach doc:name="For Each">
			<ee:transform doc:name="Transform to JSON">
				<ee:message>
					<ee:set-payload><![CDATA[%dw 2.0
output application/json
ns ns0 urn:core_2020_2.platform.webservices.netsuite.com
---
payload.ns0#record
]]></ee:set-payload>
				</ee:message>
			</ee:transform>
			<logger level="INFO" doc:name="Logger" message="#[payload]"/>
		</foreach>
	</flow>
</mule>
```

## Employee Basic Search Filtering by the Boolean and String Fields

This example shows how to use the `Search` operation to obtain the inactive `Employee` records that
have last names beginning with a specified letter.

This example requires that at least one employee record in the NetSuite instance meets the search
conditions.

The following screenshot shows the Studio app flow for the Employee basic search example:

![App flow for the Employee basic search example](/mulesoft/current/en-us/netsuite-connector/11.10/_images/netsuite-examples-search-employee.png)

Figure 2. Employee basic search app flow in Studio

Creating this example involves creating a new Mule project and configuring `HTTP Listener`, the
NetSuite Connector `Search` operation, one `For Each` component, and two `Transform Message`
components.

### Configure HTTP Listener

Configure HTTP Listener to initiate a Mule flow when a call is made to the `/employee` path on
localhost port 8081:

1.  In Studio, click **HTTP** and drag the **Listener** operation to the canvas.

2.  Change the display name of the **Listener** operation to `/employee`.

3.  Either select an existing global element or create a new one for **HTTP Listener** and keep the
    defaults.

4.  On the Listener properties window, set the **Path** field value to `/employee`.

### Add the First Transform Message Component

This **Transform Message** component contains the search criteria for the flow:

1.  From the **Mule Palette** view, drag the **Transform Message** component to the right of
    **Listener**.

2.  Change the name of the **Transform Message** component to `Search Criteria`.

3.  Click the **Transform Message** component.

    The **Output** column displays the metadata of the **AccountSearchBasic** object. You can build
    up the criteria from there, or copy the criteria below.

    The value `attributes.queryParams["isInactive"]` directs the connector to search for inactive
    employee accounts, and the value `attributes.queryParams["lastName"]` directs the connector to
    search employee which last names start with the value provided.

The DataWeave code should look like this:

```dataweave
%dw 2.0
output application/xml
ns ns0  urn:messages_2020_2.platform.webservices.netsuite.com
ns ns01 urn:common_2020_2.platform.webservices.netsuite.com
ns ns02 urn:core_2020_2.platform.webservices.netsuite.com
ns xsi http://www.w3.org/2001/XMLSchema-instance
---
{
	ns0#search: {
		ns0#searchRecord @("xmlns:ns01": ns01, xsi#"type": "ns01:EmployeeSearchBasic"): {
			ns01#lastName @(operator: "startsWith"): {
				ns02#searchValue: attributes.queryParams["lastName"]
			},
			ns01#isInactive: {
				ns02#searchValue: attributes.queryParams["isInactive"]
			}
		}
	}
}
```

### Add the NetSuite Connector Search Operation

1.  From the **Mule Palette** view, select **NetSuite** and drag the **Search** operation to the
    right of **Search Criteria**.

2.  Change the display name of the **Search** operation to `Search Employee`.

3.  Select an existing global element or create a new one for the **Search** operation.

4.  On the Search properties window:

    - In the **Key** field, select `EmployeeSearchBasic`.

    - Set the **Page Size** field value to an integer value between `10` and `1000`.

### Add the For Each Component

From the **Mule Palette** view, select **Core** and drag the **For Each** component to the right of
**Search Employee**.

### Add the Second Transform Message Component

This **Transform Message** component converts the response to JSON format:

1.  From the **Mule Palette** view, drag a **Transform Message** component inside the **For Each**
    component.

2.  Change the name of the **Transform Message** component to `Response to JSON`.

3.  Click the **Transform Message** component and set the output to `application/json`.

    ```dataweave
    %dw 2.0
    output application/json
    ns ns0 urn:core_2020_2.platform.webservices.netsuite.com
    ---
    payload.ns0#record
    ```

4.  Finally, drag and drop a **Logger** component from the **Mule Palette** view, to the right of
    **Response to JSON**. the message should be `#[payload]`

### Run the App

1.  Start the Mule app.

2.  Call `http://localhost:8081/employee?isInactive=true&lastName=C` to retrieve the inactive
    `Employee` records that have last names beginning with `C`.

3.  You will **ONLY** be able to see the output from the Mule App console.

### XML for Employee Basic Search Flow

Paste this code into a new Mule app in Studio to quickly load the flow for the Employee basic search
example. If needed, change the values to reflect your environment.

```xml
<?xml version="1.0" encoding="UTF-8"?>

<mule
    xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
	xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns:netsuite="http://www.mulesoft.org/schema/mule/netsuite" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 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/netsuite http://www.mulesoft.org/schema/mule/netsuite/current/mule-netsuite.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/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>
	<netsuite:config name="tokenConfig" doc:name="NetSuite SOAP Config">
		<netsuite:token-based-authentication-connection consumerKey="${netsuite.consumerKey}" consumerSecret="${netsuite.consumerSecret}" tokenId="${netsuite.tokenId}" tokenSecret="${netsuite.tokenSecret}" account="${netsuite.account}"/>
	</netsuite:config>

    <flow name="employee-basic-search-flow">
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="employee"/>
		<ee:transform doc:name="Search Criteria">
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/xml
ns ns0  urn:messages_2020_2.platform.webservices.netsuite.com
ns ns01 urn:common_2020_2.platform.webservices.netsuite.com
ns ns02 urn:core_2020_2.platform.webservices.netsuite.com
ns xsi http://www.w3.org/2001/XMLSchema-instance
---
{
	ns0#search: {
		ns0#searchRecord @("xmlns:ns01": ns01, xsi#"type": "ns01:EmployeeSearchBasic"): {
			ns01#lastName @(operator: "startsWith"): {
				ns02#searchValue: attributes.queryParams["lastName"]
			},
			ns01#isInactive: {
				ns02#searchValue: attributes.queryParams["isInactive"]
			}
		}
	}
}
]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<netsuite:search doc:name="Search Employee" config-ref="tokenConfig" key="EmployeeSearchBasic"/>
		<foreach doc:name="For Each">
			<ee:transform doc:name="Transform to JSON">
				<ee:message >
					<ee:set-payload ><![CDATA[%dw 2.0
output application/json
ns ns0 urn:core_2020_2.platform.webservices.netsuite.com
---
payload.ns0#record
]]></ee:set-payload>
				</ee:message>
			</ee:transform>
			<logger level="INFO" doc:name="Logger" message="#[payload]" />
		</foreach>
	</flow>
</mule>
```

## Customer Advanced Search Filtering by Stage field and Date Created field

This example shows how to use the `Search` operation to obtain the customer records that were
created after 2015 and that are in the `LEAD` stage.

This examples requires that at least one customer record meets the search conditions in the NetSuite
instance.

The following screenshot shows the Studio app flow for this example:

![App flow for the Customer advanced search example](/mulesoft/current/en-us/netsuite-connector/11.10/_images/netsuite-examples-search-customer.png)

Figure 3. Customer advanced search app flow in Studio

Creating this example involves creating a new Mule project and configuring `HTTP Listener`, the
NetSuite `Search` operation, two `Transform Message` components, and a `For-Each` component.

### Configure HTTP Listener

Configure HTTP Listener to initiate a Mule flow when a call is made to the `/customer` path on
localhost port 8081:

1.  In Studio, click **HTTP** and drag the **Listener** operation to the canvas.

2.  Change the display name of the **Listener** operation to `/customer`.

3.  Select an existing global element or create a new one for the **Listener** operation.

4.  On the Listener properties window, set the **path** field value to `/customer`.

### Add the First Transform Message Component

This **Transform Message** component specifies the search criteria for the flow:

1.  From the **Mule Palette** view, drag the **Transform Message** component to the right of
    **Listener**.

2.  Change the name of the **Transform Message** component to `Search Criteria`.

3.  Click the **Transform Message** component.

    The **Output** column displays the metadata of the **CustomerSearchAdvanced** object. You can
    build up the criteria from there, or copy the criteria below.

    Setting the **searchValue** of `stage` to `attributes.queryParams["stage"]` directs the
    connector to use the value of the `stage` query parameter.

The DataWeave code should look like this:

```dataweave
%dw 2.0
output application/xml
ns ns0 urn:messages_2020_2.platform.webservices.netsuite.com
ns ns01 urn:common_2020_2.platform.webservices.netsuite.com
ns ns02 urn:core_2020_2.platform.webservices.netsuite.com
ns ns03 urn:relationships_2020_2.lists.webservices.netsuite.com
ns xsi http://www.w3.org/2001/XMLSchema-instance
---
{
	ns0#search: {
		ns0#searchRecord @("xmlns:ns03": ns03, xsi#"type": "ns03:CustomerSearchAdvanced"): {
			ns03#criteria: {
				ns03#basic: {
					ns01#stage @(operator: "anyOf"): {
						ns02#searchValue: [attributes.queryParams["stage"]]
					},
					ns01#dateCreated @(operator: "after"): {
						ns02#searchValue: "2015-01-01T00:00:00.000-08:00"
					}
				}
			}
		}
	}
}
```

### Add the NetSuite Connector Search Operation

1.  From the **Mule Palette** view, select **NetSuite** and drag the **Search** operation to the
    right of **Search Criteria**.

2.  Change the display name of the **Search** operation to `Search Customer Advanced`.

3.  Select an existing global element or create a new one for the **Search** operation.

4.  On the Search properties window:

    - In the **Key** field, select `CustomerSearchAdvanced`.

    - Set the **Page Size** field value to an integer value between `10` and `1000`.

    - Click on **Search Preferences** and select `false` on `Return search columns`

### Add a For-Each Component

A `For-Each` component processes each record on the list returned by the `Search` operation
individually so that the records can be displayed on the console.

1.  From the **Mule Palette** view, drag a **For-Each** component to the right of **Search**.

2.  Drag a **Transform Message** component inside the **For Each** box, rename the component to
    `Response to JSON`, and replace the DataWeave code with this code:

    ```dataweave
    %dw 2.0
    output application/json
    ns ns0 urn:core_2020_2.platform.webservices.netsuite.com
    ---
    payload.ns0#record
    ```

3.  Drag a **Logger** component from the **Mule Palette** view to the right of **Transform**, inside
    the **For Each** box.

4.  On the Logger properties window, set the **Message** field value to `#[payload]`.

### Run the App

1.  Start the Mule app.

2.  Call `http://localhost:8081/customer?stage=LEAD`.

3.  You will **ONLY** be able to see the output from the Mule App console.

### XML for the Customer Advanced Search Flow

Paste this code into a new Mule app in Studio to quickly load the flow for the Customer Advanced
Search example. If needed, change the values to reflect your environment.

```xml
<?xml version="1.0" encoding="UTF-8"?>

<mule
    xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
	xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns:netsuite="http://www.mulesoft.org/schema/mule/netsuite" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 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/netsuite http://www.mulesoft.org/schema/mule/netsuite/current/mule-netsuite.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/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>
	<netsuite:config name="tokenConfig" doc:name="NetSuite SOAP Config">
		<netsuite:token-based-authentication-connection consumerKey="${netsuite.consumerKey}" consumerSecret="${netsuite.consumerSecret}" tokenId="${netsuite.tokenId}" tokenSecret="${netsuite.tokenSecret}" account="${netsuite.account}"/>
	</netsuite:config>

    <flow name="customer-advanced-search-flow">
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="customer" />
		<ee:transform doc:name="Search Criteria">
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/xml
ns ns0 urn:messages_2020_2.platform.webservices.netsuite.com
ns ns01 urn:common_2020_2.platform.webservices.netsuite.com
ns ns02 urn:core_2020_2.platform.webservices.netsuite.com
ns ns03 urn:relationships_2020_2.lists.webservices.netsuite.com
ns xsi http://www.w3.org/2001/XMLSchema-instance
---
{
	ns0#search: {
		ns0#searchRecord @("xmlns:ns03": ns03, xsi#"type": "ns03:CustomerSearchAdvanced"): {
			ns03#criteria: {
				ns03#basic: {
					ns01#stage @(operator: "anyOf"): {
						ns02#searchValue: [attributes.queryParams["stage"]]
					},
					ns01#dateCreated @(operator: "after"): {
						ns02#searchValue: "2015-01-01T00:00:00.000-08:00"
					}
				}
			}
		}
	}
}]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<netsuite:search doc:name="Search Customer Advanced" config-ref="tokenConfig" returnSearchColumns="false" key="CustomerSearchAdvanced"/>
		<foreach doc:name="For Each">
			<ee:transform doc:name="Transform to JSON">
			<ee:message>
				<ee:set-payload><![CDATA[%dw 2.0
output application/json
ns ns0 urn:core_2020_2.platform.webservices.netsuite.com
---
payload.ns0#record
]]></ee:set-payload>
			</ee:message>
		</ee:transform>
			<logger level="INFO" doc:name="Logger" message="#[payload]" />
		</foreach>
	</flow>
</mule>
```

## Add a File

This example shows how to use the **Add** operation to add a file using NetSuite Connector.

The following screenshot shows the Studio app flow for this example:

![App flow for the Add File example](/mulesoft/current/en-us/netsuite-connector/11.10/_images/add-file.png)

Creating this example involves creating a new Mule project and configuring a **Listener** component,
**Transform Message** component, **Add** operation, and **Logger** component.

### Configure HTTP Listener

Configure HTTP Listener to initiate a Mule flow when a call is made to the `/upload` path:

1.  Create a new Mule project in Studio.

2.  In Studio, click **HTTP** and drag the **Listener** component to the canvas.

3.  In the **Listener** properties window, click **+** next to the **Connector configuration** field
    to add a global element.

4.  Accept the defaults.

5.  In the **Listener** properties window, set the **Path** field value to `/upload`.

### Add the Transform Message Component

Add the **Transform Message** component to convert the values from the HTTP input to XML format so
they can be used as input for the **Add** operation:

1.  From the **Mule Palette** view, select **Core** and drag a **Transform Message** component to
    the right of **Listener**.

2.  In the properties window, overlay the brackets in the **Output** section with this DataWeave
    code:

    ```dataweave
    %dw 2.0
    output application/xml
    ns ns0 urn:messages_2020_2.platform.webservices.netsuite.com
    ns ns01 urn:filecabinet_2020_2.documents.webservices.netsuite.com
    ns xsi http://www.w3.org/2001/XMLSchema-instance
    ns ns02 urn:core_2020_2.platform.webservices.netsuite.com
    ---
    {
    	ns0#add: {
    		ns0#record @("xmlns:ns01": ns01, xsi#"type": "ns01:File"): {
    			ns01#name: "test.csv",
    			ns01#content: "Here is the content of file",
    			ns01#folder @(internalId: 826997 , xsi#"type": "ns01:RecordRef"): {
    				ns02#name: null
    			}
    		}
    	}
    }
    ```

### Add the Add Operation

Add the **Add** operation to add a file using the values passed by the **Transform Message**
component:

1.  From the **Mule Palette** view, select **NetSuite** and drag the **Add** operation to the right
    of **Transform Message**.

2.  In the properties window, click **+** next to the **Connector configuration** field to add a
    global element.

3.  Configure the global element depending on the connection, for example:

    <table><colgroup><col> <col></colgroup><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody><tr><td><p>Consumer key</p></td><td><p><code>${netsuite.consumerKey}</code></p></td></tr><tr><td><p>Consumer secret</p></td><td><p><code>${netsuite.consumerSecret}</code></p></td></tr><tr><td><p>Token ID</p></td><td><p><code>${netsuite.tokenId}</code></p></td></tr><tr><td><p>Token secret</p></td><td><p><code>${netsuite.tokenSecret}</code></p></td></tr><tr><td><p>Account Id</p></td><td><p><code>${netsuite.account}</code></p></td></tr><tr><td><p>Signature algorithm</p></td><td><p><code>HMAC_SHA256</code></p></td></tr><tr><td><p>Wsdl version</p></td><td><p><code>V2020_2</code></p></td></tr><tr><td><p>SOAP Port</p></td><td><p><code>services/NetSuitePort_2020_2</code></p></td></tr></tbody></table>

    The following image shows an example of the **Add** configuration of the global element:

    ![Add operation global element configuration window](/mulesoft/current/en-us/netsuite-connector/11.10/_images/add-config-window.png)

4.  In the properties window, configure the following fields:

    <table><colgroup><col> <col></colgroup><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody><tr><td><p>Display Name</p></td><td><p>Name for the connector operation.</p></td></tr><tr><td><p>Connector configuration</p></td><td><p>Global configuration you just created.</p></td></tr><tr><td><p>Type</p></td><td><p><code>file</code></p></td></tr><tr><td><p>Message</p></td><td><p><code>vars.fileRecord</code></p></td></tr></tbody></table>

    The following image shows an example of the **Add** configuration in the properties window:

    ![Add operation properties window configuration](/mulesoft/current/en-us/netsuite-connector/11.10/_images/add-properties-window.png)

### Add the Logger Component

Add the **Logger** component to display the response in the Mule console:

1.  From the **Mule Palette** view, select **Core** and drag a **Logger** component to the right of
    **Add**.

2.  In the properties window, configure the following fields:

    <table><colgroup><col> <col></colgroup><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody><tr><td><p>Display Name</p></td><td><p>Name for the logger, such as <code>Logger</code>.</p></td></tr><tr><td><p>Message</p></td><td><p><code>The file was added</code></p></td></tr><tr><td><p>Level</p></td><td><p>INFO (Default)</p></td></tr></tbody></table>

    The following image shows an example of the **Logger** configuration in the properties window:

    ![Logger properties window configuration](/mulesoft/current/en-us/netsuite-connector/11.10/_images/add-file-logger.png)

### Run the App

To run the app:

1.  Start the Mule app.

2.  Call `http://localhost:8081/upload` to add the file.

### XML for the Add File Flow

Paste this code into a new Mule app in Studio to quickly load the flow for the Add File example. If
needed, change the values to reflect your environment.

```xml
<?xml version="1.0" encoding="UTF-8"?>
​
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns:file="http://www.mulesoft.org/schema/mule/file"
	xmlns:netsuite="http://www.mulesoft.org/schema/mule/netsuite"
	xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
	xmlns="http://www.mulesoft.org/schema/mule/core"
	xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 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/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.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/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
​

	  <netsuite:config name="NetSuite_Config1" doc:name="NetSuite Config"
		doc:id="510151ba-ce6a-4401-8901-4269280d09d1" > <netsuite:token-based-authentication-connection
		consumerKey="${netsuite.consumerKey}" consumerSecret="${netsuite.consumerSecret}"
		tokenId="${netsuite.tokenId}" tokenSecret="${netsuite.tokenSecret}" account="${netsuite.account}"
		soapPort="services/NetSuitePort_2020_2" wsdlVersion="V2020_2"> </netsuite:token-based-authentication-connection> </netsuite:config>
​
​
	<configuration-properties
		doc:name="Configuration properties"
		doc:id="b2a18b7c-9a82-41d3-828e-7bdd488ddf13" file="config.yaml" />

	<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="f5d39893-7a0e-42fb-9272-953b705adafa" >
		<http:listener-connection host="0.0.0.0" port="8081" />
	</http:listener-config>

	<flow name="test-netsuite-appFlow"
		doc:id="07490264-2157-4937-922b-d58199505338">


		<http:listener doc:name="Listener" doc:id="4fbbf511-2f66-44a3-bcf5-05094e2b92e7" config-ref="HTTP_Listener_config" path="/upload"/>
		<ee:transform doc:name="fileRecord" doc:id="50c11321-c8a9-47ba-a06e-7a26b0aefcfb" >
            <ee:message >
            </ee:message>
            <ee:variables >
                <ee:set-variable variableName="fileRecord" ><![CDATA[%dw 2.0
output application/xml
ns ns0 urn:messages_2020_2.platform.webservices.netsuite.com
ns ns01 urn:filecabinet_2020_2.documents.webservices.netsuite.com
ns xsi http://www.w3.org/2001/XMLSchema-instance
ns ns02 urn:core_2020_2.platform.webservices.netsuite.com
---
{
	ns0#add: {
		ns0#record @("xmlns:ns01": ns01, xsi#"type": "ns01:File"): {
			ns01#name: "test.csv",
			ns01#content: "Here is the content of file",
			ns01#folder @(internalId: 826997 , xsi#"type": "ns01:RecordRef"): {
				ns02#name: null
			}
		}
	}
}]]></ee:set-variable>
            </ee:variables>
        </ee:transform>
		<netsuite:add doc:name="Add" doc:id="ddc65bfd-73b5-4a8f-9bd7-bafe4e479db7" config-ref="NetSuite_Config1" type="file">
				<netsuite:message ><![CDATA[#[vars.fileRecord]]]></netsuite:message>
		</netsuite:add>
		<logger level="INFO" doc:name="Logger"
			doc:id="1f48613a-8a9e-4baa-8787-c4531a8e620e" message="The file was added"/>
	</flow>
</mule>
```

## Custom Records and Fields

The following example shows how to add, get, and delete custom records with custom fields using
DataWeave. Use DataSense, which imports metadata from NetSuite Connector, to simplify application
design.

The following screenshot shows the Studio app flow for this example:

![App flow for the Custom Records example](/mulesoft/current/en-us/netsuite-connector/11.10/_images/custom-record-flow.png)

Creating this example involves adding the **Add** operation, **Set Variable** component, **Get**
operation, and **Delete** operation.

### Add a Custom Record

Add a custom record with custom fields using the **Add** operation.

Include the following attributes to add a custom record:

- **separators**

  Specifies a separator character. The separator in the following example is `__`.

- **recordType**

  References the custom record type. The recordType in the following example is `customRecordType`.

- **scriptId**

  References the script ID of the record. The scriptId in the following example is
  `customrecord_2663_bank_details`.

- **internalId**

  References the internal ID of the record. The internalId in the following example is `374`.

- **XSI type**

  Specify the XSI type as **CustomRecordRef** to add a custom record.

The following DataWeave script adds a custom record with custom fields:

%dw 2.0 output application/xml ns ns0 urn:messages\_2020\_2.platform.webservices.netsuite.com ns
ns01 urn:customization\_2020\_2.setup.webservices.netsuite.com ns ns02
urn:core\_2020\_2.platform.webservices.netsuite.com ns xsi http://www.w3.org/2001/XMLSchema-instance
---

{ ns0#add: { ns0#record @("xmlns:ns01": ns01, xsi#"type": "ns01:CustomRecord"): {
ns01#customFieldList: { StringCustomFieldRef\_\_custrecord\_2663\_legal\_name\_\_3878: { ns02#value:
"test" }, LongCustomFieldRef\_\_custrecord\_2663\_eft\_file\_cabinet\_id\_\_3874: { ns02#value: 1234
}, BooleanCustomFieldRef\_\_custrecord\_2663\_dd\_batch\_\_3864: { ns02#value: true } } } } }

The customFieldList contains the customFields for the entity you use.

The example above shows `StringCustomFieldRef__custrecord_2663_legal_name__3878`,
`BooleanCustomFieldRef__custrecord_2663_dd_batch__3864` and
`LongCustomFieldRef__custrecord_2663_eft_file_cabinet_id__3874`. The field names consist of a
**scriptId**, **internalId**, and **CustomRecordRef** type.

`StringCustomFieldRef__custrecord_2663_legal_name__3878` has a specified value `ns02#value: "test"`,
`LongCustomFieldRef__custrecord_2663_eft_file_cabinet_id__3874` has a specified value
`ns02#value: 1234`, and `BooleanCustomFieldRef__custrecord_2663_dd_batch__3864` has a specified
value `ns02#value: true`.

### Get Custom Record

Get a custom record with custom fields using the **Get** operation.

Include the following attributes to get a custom record:

- **typeId**

  References the custom record type Id. The typeId in the following example is `374`.

- **internalId**

  References the internalId of the record. The internalId in the following example is
  `vars.responseInternalId`.

- **XSI type**

  Specify the XSI type as **CustomRecordRef** to retrieve a custom record.

The following DataWeave script gets a custom record with custom fields:

%dw 2.0 output application/xml ns ns0 urn:messages\_2020\_2.platform.webservices.netsuite.com ns
ns01 urn:core\_2020\_2.platform.webservices.netsuite.com ns xsi http://www.w3.org/2001/XMLSchema-instance
---

{ ns0#get: { ns01#baseRef @(internalId: vars.responseInternalId , "typeId": "374", xsi#"type":
"ns01:CustomRecordRef"): null } }

### Delete Custom Record

Delete a custom record with custom fields using the **Delete** operation.

Include the following attributes to delete a custom record:

- **typeId**

  References the custom record type Id. The typeId in the following example is `374`.

- **internalId**

  References the internalId of the record. The internalId in the following example is
  `vars.responseInternalId`.

- **XSI type**

  Specify the XSI type as **CustomRecordRef** to delete a custom record.

The following DataWeave script deletes a custom record with custom fields:

%dw 2.0 output application/xml ns ns0 urn:messages\_2020\_2.platform.webservices.netsuite.com ns
ns01 urn:core\_2020\_2.platform.webservices.netsuite.com ns xsi http://www.w3.org/2001/XMLSchema-instance
---

{ ns0#delete: { ns01#baseRef @(internalId: vars.responseInternalId , "typeId": "374", xsi#"type":
"ns01:CustomRecordRef"): null } }

### XML for Custom Records

Paste this code into a new Mule app in Studio to quickly load the flow for the custom records
example. If needed, change the values to reflect your environment.

```xml
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:netsuite="http://www.mulesoft.org/schema/mule/netsuite"
	xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://www.mulesoft.org/schema/mule/core"
	xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
	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
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
	<flow name="recordWithCustomFields">
		<netsuite:add doc:name="Add"
			doc:id="e8643704-bba5-4156-83b7-73650b2661ac"
			config-ref="tokenConfig" type="__customRecordType__customrecord_2663_bank_details__374">
			<netsuite:message><![CDATA[#[%dw 2.0
output application/xml
ns ns0 urn:messages_2020_2.platform.webservices.netsuite.com
ns ns01 urn:customization_2020_2.setup.webservices.netsuite.com
ns ns02 urn:core_2020_2.platform.webservices.netsuite.com
ns xsi http://www.w3.org/2001/XMLSchema-instance
---
{
	ns0#add: {
		ns0#record @("xmlns:ns01": ns01, xsi#"type": "ns01:CustomRecord"): {
			ns01#customFieldList: {
				StringCustomFieldRef__custrecord_2663_legal_name__3878: {
					ns02#value: "test"
				},
				LongCustomFieldRef__custrecord_2663_eft_file_cabinet_id__3874: {
					ns02#value: 1234
				},
				BooleanCustomFieldRef__custrecord_2663_dd_batch__3864: {
					ns02#value: true
				}
			}
		}
	}
}]]]></netsuite:message>
		</netsuite:add>
		<set-variable
			value="#[%dw 2.0&#10;output application/java&#10;ns ns0 http://schemas.xmlsoap.org/soap/envelope/&#10;ns ns01 urn:messages_2020_2.platform.webservices.netsuite.com&#10;---&#10;payload.ns01#addResponse.ns01#writeResponse.ns01#baseRef.@internalId]"
			doc:name="Set Variable" doc:id="0fc988de-84a2-45f1-a991-e01328d38d7f"
			variableName="responseInternalId" />
		<netsuite:get doc:name="Get record"
			doc:id="b4904b67-0fd9-468e-a649-b8d6bd54e2c4"
			config-ref="tokenConfig" refType="CustomRecordRef" type="__customRecordType__customrecord_2663_bank_details__374">
			<netsuite:message><![CDATA[#[%dw 2.0
output application/xml
ns ns0 urn:messages_2020_2.platform.webservices.netsuite.com
ns ns01 urn:core_2020_2.platform.webservices.netsuite.com
ns xsi http://www.w3.org/2001/XMLSchema-instance
---
{
	ns0#get: {
		ns01#baseRef @(internalId: vars.responseInternalId , "typeId": "374", xsi#"type": "ns01:CustomRecordRef"): null
	}
}]]]></netsuite:message>
		</netsuite:get>
		<netsuite:delete doc:name="Delete record"
			doc:id="fd4d9343-759b-4c08-a74d-a66f04c5c513"
			config-ref="tokenConfig" type="__customRecordType__customrecord_2663_bank_details__374" refType="CustomRecordRef">
			<netsuite:message><![CDATA[#[%dw 2.0
output application/xml
ns ns0 urn:messages_2020_2.platform.webservices.netsuite.com
ns ns01 urn:core_2020_2.platform.webservices.netsuite.com
ns xsi http://www.w3.org/2001/XMLSchema-instance
---
{
	ns0#delete: {
		ns01#baseRef @(internalId: vars.responseInternalId , "typeId": "374", xsi#"type": "ns01:CustomRecordRef"): null
	}
}]]]></netsuite:message>
		</netsuite:delete>
	</flow>
</mule>
```

## See Also

- [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors)

- [Salesforce Help](https://help.salesforce.com)
