Implementing NetSuite Saved Search with MuleSoft
NetSuite is a SaaS-based ERP which allows companies to manage important business using a single tool. MuleSoft provides a NetSuite connector, which enables to automate the business process and synchronize the data between NetSuite and third-party tools.
Introduction
NetSuite is a SaaS-based ERP which allows companies to manage important business using a single tool. NetSuite provides a suite of cloud-based financials / Enterprise Resource Planning (ERP) and omnichannel commerce software. NetSuite has capabilities of ERP, CRM, Manufacturing, e-commerce, retail.
MuleSoft provides a NetSuite connector, which enables to automate the business process and synchronize the data between NetSuite and third-party tools. NetSuite Connector uses SuiteTalk WSDL to provide SOAP-based integration to generate NetSuite business objects, make use of different authentication levels, and support error handling.
NetSuite connector provides various features and capabilities:
- SOAP-Based integration.
- Connecting NetSuite using REST calls to RESTlets that expose APIs created with SuiteScript.
- Multiple types of Authentication.
- Error Handling support.
How to Connect NetSuite with MuleSoft
MuleSoft NetSuite connector provides various ways of Authentication to connect NetSuite.
- Login authentication.
- Request based authentication.
- SSO authentication.
- Token authentication.

One of the most common ways of connecting NetSuite is using Token authentication. For this, we will need Consumer key, Consumer secret, Token ID, and Token secret.

Now, we are going to see a few operations related to NetSuite.
Saved Search
Saved Search allows us to search the data in NetSuite and it can be performed on any record type in NetSuite. MuleSoft provides the operation Search which can be used to perform the search on the record type.
Use Case 1 - Basic Employee Search (lastName starts with J)
Let’s consider, we want to retrieve all the Employee details from NetSuite whose lastName starts with “J”. MuleSoft’s search operation in the NetSuite connector can be used to retrieve all employee details whose lastName starts with “J”.
We will be adding the following script in MuleSoft Transform Message to pass as Payload to NetSuite connector for the search operation and record type as EMPLOYEE_BASIC.
%dw 2.0
output application/java
---
{
lastName: {
operator: "STARTS_WITH",
searchValue: "J"
}
} as Object {
class: "org.mule.module.netsuite.extension.api.EmployeeSearchBasic"
}
NetSuite Connector Configuration

Use Case 2 - Advanced Employee Search
Let’s consider, we want to retrieve all the employee details from NetSuite. NetSuite has created Saved Search which can be utilized in the MuleSoft application to fetch all employee details.
NetSuite provided us savedSearchId as “8656” and savedSearchScriptId as “EmployeeSearch8656”.
We will be adding the following script in MuleSoft Transform Message to pass as Payload to NetSuite connector for the search operation and record type as EMPLOYEE_ADVANCED.
%dw 2.0
output application/java
---
{
savedSearchId: "8656",
savedSearchScriptId: "EmployeeSearch8656"
} as Object {
class: "org.mule.module.netsuite.extension.api.EmployeeSearch"
} as Object {
class: "org.mule.module.netsuite.extension.api.EmployeeSearchAdvanced"
}
NetSuite Connector Configuration

Use Case 3 - Advanced Employee Search (lastModifiedDate is after 1st August 2020)
Let’s consider, we want to retrieve all the Employees details from NetSuite whose lastModifiedDate is after 1st August 2020. NetSuite has created Saved Search which can be utilized in the MuleSoft application to fetch all employee details whose lastModifiedDate is after 1st August 2020.
NetSuite provided us savedSearchId as “8657” and savedSearchScriptId as “EmployeeSearch8657”.
We will be adding the following script in MuleSoft Transform Message to pass as Payload to NetSuite connector for the search operation and record type as EMPLOYEE_ADVANCED.
%dw 2.0
output application/java
---
{
savedSearchId: "EmployeeSearch8657",
savedSearchScriptId: "EmployeeSearch8657",
criteria: {
basic: {
lastModifiedDate: {
operator: "AFTER",
searchValue: "2020-08-01T12:00:00" as LocalDateTime {format: "yyyy-MM-dd'T'HH:mm:ss"}
} as Object {
class: "org.mule.module.netsuite.extension.api.SearchDateField"
}
} as Object {
class: "org.mule.module.netsuite.extension.api.EmployeeSearchBasic"
}
} as Object {
class: "org.mule.module.netsuite.extension.api.EmployeeSearch"
}
} as Object {
class: "org.mule.module.netsuite.extension.api.EmployeeSearchAdvanced"
}
Use Case 4 - Advanced Employee Search (isInactive is false and retrieve firstName, middleName and lastName)
Let’s consider, we want to retrieve all the Employees details from NetSuite who are active and retrieve only firstName, middleName, and lastName.
We will be adding the following script in MuleSoft Transform Message to pass as Payload to NetSuite connector for the search operation and record type as EMPLOYEE_ADVANCED.
%dw 2.0
output application/java
---
{
columns: {
basic: {
firstName: [{
customLabel: "First Name"
}],
middleName: [{
customLabel: "Middle Name"
}],
lastName: [{
customLabel: "Last Name"
}]
}
},
criteria: {
basic: {
isInactive: {
searchValue: false
}
}
}
} as Object {
class: "org.mule.module.netsuite.extension.api.CustomerSearchAdvanced"
}
Use Case 5 - Basic employee search (lastModifiedDate is after 1st August 2020 and isInactive is false)
Let’s consider, we want to retrieve all the Employees details from the NetSuite who are active and lastModifiedDate is after 1st August 2020.
We will be adding the following script in MuleSoft Transform Message to pass as Payload to NetSuite connector for the search operation and record type as EMPLOYEE_BASIC.
%dw 2.0
output application/java
---
{
lastModifiedDate: {
operator: "AFTER",
searchValue: "2020-08-01T12:00:00" as LocalDateTime {format: "yyyy-MM-dd'T'HH:mm:ss"}
},
isInactive{
searchValue: false
},
} as Object {
class: "org.mule.module.netsuite.extension.api.EmployeeSearchBasic"
}
Now, you know how to perform search operations with the MuleSoft NetSuite connector.
FAQs
Frequently asked questions about this post.
-
What authentication methods does the MuleSoft NetSuite connector support?
The connector provides Login authentication, Request based authentication, SSO authentication, and Token authentication, with Token authentication being one of the most common ways to connect NetSuite.
-
What do I need to connect to NetSuite using Token authentication?
For Token authentication you need a Consumer key, a Consumer secret, a Token ID, and a Token secret.
-
How do I run a basic employee search where lastName starts with "J"?
Use the connector's Search operation with the record type set to
EMPLOYEE_BASIC, and pass a Transform Message payload that setslastNamewithoperator: "STARTS_WITH"andsearchValue: "J", cast as anEmployeeSearchBasicobject. -
How do I use a NetSuite Saved Search from MuleSoft?
Run the Search operation with the record type
EMPLOYEE_ADVANCEDand pass a payload containing thesavedSearchIdandsavedSearchScriptIdthat NetSuite provided (for examplesavedSearchId: "8656"andsavedSearchScriptId: "EmployeeSearch8656"), cast through theEmployeeSearchandEmployeeSearchAdvancedclasses. -
How do I return only specific fields like firstName, middleName, and lastName from a search?
Use an advanced search where the payload sets a
columns.basicsection listingfirstName,middleName, andlastName(each with acustomLabel), alongside any criteria such asisInactivewithsearchValue: falseto limit results to active employees. -
What is the difference between a basic search and an advanced search in these examples?
A basic search casts the payload to a class like
EmployeeSearchBasicand uses theEMPLOYEE_BASICrecord type for straightforward field filters, while an advanced search uses theEMPLOYEE_ADVANCEDrecord type and supports Saved Searches plus separatecriteriaandcolumnssections cast throughEmployeeSearchAdvanced.