{{announcement.body}}
{{announcement.title}}

Implementing NetSuite Saved Search With MuleSoft - Part 1

DZone 's Guide to

Implementing NetSuite Saved Search With MuleSoft - Part 1

This tutorial walks you through how to perform a search operation with MuleSoft NetSuite connector.

· Integration Zone ·
Free Resource

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 provided various ways of Authentication to connect NetSuite.

  • Login authentication.
  • Request based authentication.
  • SSO authentication.
  • Token authentication.

choose token authentication

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

adding consumer key, consumer secret, token ID, and token secret

Now, we are going to see few operations related to Netsuite.

Saved Search

Saved Search allows us to search the data in the NetSuite and search 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 the NetSuite whose lastName starts with "J". MuleSoft search operation in NetSuite connector can be utilized to retrieve all employees details whose lastName starts with "J".

We will be adding the below script in MuleSoft Transform Message to pass as Payload to NetSuite connector for search operation and record type as "EMPLOYEE_BASIC".

JSON
 




x





1
%dw 2.0
2
output application/java
3
---
4
{
5
    lastName: {
6
        operator: "STARTS_WITH",
7
        searchValue: "J"
8
   }
9
    } as Object {
10
    class : "org.mule.module.netsuite.extension.api.EmployeeSearchBasic"
11
}


NetSuite Connector Configuration

employee_basic key

Use Case 2 - Advanced Employee Search

Let's consider, we want to retrieve all the Employee details from the 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 below script in MuleSoft Transform Message to pass as Payload to NetSuite connector for search operation and record type as "EMPLOYEE_ADVANCED".

JSON
 




xxxxxxxxxx
1
11


1
%dw 2.0
2
output application/java
3
---
4
{
5
savedSearchId : "8656",
6
savedSearchScriptId : "EmployeeSearch8656"
7
}
8
as Object {  class : "org.mule.module.netsuite.extension.api.EmployeeSearch" }   
9
as Object {
10
class : "org.mule.module.netsuite.extension.api.EmployeeSearchAdvanced"
11
}


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 the 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 below script in MuleSoft Transform Message to pass as Payload to NetSuite connector for search operation and record type as "EMPLOYEE_ADVANCED".

JSON
 




x




1
%dw 2.0
2
output application/java
3
---
4
{
5
    savedSearchId : "EmployeeSearch8657",   
6
    savedSearchScriptId : "EmployeeSearch8657",
7
        criteria : { 
8
            basic : {
9
              lastModifiedDate: {
10
                operator: "AFTER",
11
                searchValue: "2020-08-01T12:00:00" as LocalDateTime {format: "yyyy-MM-dd'T'HH:mm:ss"}
12
                }as Object {  class : "org.mule.module.netsuite.extension.api.SearchDateField"   }
13
            }as Object {  class : "org.mule.module.netsuite.extension.api.EmployeeSearchBasic" }
14
        
15
        }as Object {  class : "org.mule.module.netsuite.extension.api.EmployeeSearch" } 
16
} 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 the NetSuite who are active and retrieve only firstName, middleName, and lastName. 

We will be adding the below script in MuleSoft Transform Message to pass as Payload to NetSuite connector for search operation and record type as "EMPLOYEE_ADVANCED".

JSON
 




x


 
1
%dw 2.0
2
output application/java
3
---
4
{
5
  columns: {
6
        basic: {
7
            firstName: [{
8
                customLabel: "First Name"
9
            }],
10
            middleName: [{
11
                customLabel: "Middle Name"
12
            }],
13
            lastName: [{
14
                    customLabel: "Last Name"
15
            }]
16
        }
17
    },
18
    criteria: {
19
        basic: {
20
            isInactive: {
21
                searchValue: false
22
            }
23
        }
24
    }
25
  } as Object {
26
        class : "org.mule.module.netsuite.extension.api.CustomerSearchAdvanced"
27
}


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 below script in MuleSoft Transform Message to pass as Payload to NetSuite connector for search operation and record type as "EMPLOYEE_BASIC".

JSON
 




x


1
%dw 2.0
2
output application/java
3
---
4
{
5
    lastModifiedDate: {
6
        operator: "AFTER",
7
        searchValue: "2020-08-01T12:00:00" as LocalDateTime {format: "yyyy-MM-dd'T'HH:mm:ss"}
8
   },
9
    isInactive{
10
        searchValue: false
11
   },
12
13
    } as Object {
14
    class : "org.mule.module.netsuite.extension.api.EmployeeSearchBasic"
15
}


Now, you know how to perform search operations with the MuleSoft NetSuite connector.

Topics:
mulesoft, mulesoft 4, netsuite

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}