Author: Masoom Goyal & Putul Mandal
- Create a mule project and add the NetSuite dependency from the mule palette as shown below:
- Add listener and give the configuration and path.
NETSUITE CONFIGURATION:
- Add NetSuite config in the global elements of the project as shown below:
- Mandatory parameters:
- CONSUMER KEY : As provided by the client.
- CONSUMER SECRET : As provided by the client.
- TOKEN ID : As provided by the client.
- TOKEN SECRET : As provided by the client.
- ACCOUNT ID : As provided by the client.
- SIGNATURE ALGORITHM : HMAC-SHA256( Provide this by yourself).
- WSDL VERSION : V2021_1( Provide this by yourself).
- SOAP PORT : services/NetsuitePort_2021_1( Provide this by yourself).
- Now check the test connection and make sure that the test connection is successful, as shown below:
NETSUITE OPERATIONS:
1. SEARCH OPERATION:
- Drag down NetSuite Search connector from mule palette and do the configuration as shown above.
- In the general section of the connector choose the key as SearchRecordBasic (you may select according to your requirement).
- Now drag a transform message before the NetSuite search connector to load the metadata.
- Click on the searchRecord, and the payload will be automatically populated in the transform message.
- To know the exact input payload, you can either refer to the soap request payload or the one which we have used below:
SOAP REQUEST THAT WE REFERRED
DW PAYLOAD AFTER MAPPING:
%dw 2.0
output application/xml
ns ns0 urn:messages_2021_1.platform.webservices.netsuite.com
ns ns01 urn:customization_2021_1.setup.webservices.netsuite.com
ns xsi http://www.w3.org/2001/XMLSchema-instance
—
{
ns0#search: {
ns0#searchRecord @(“xmlns:ns01″: ns01, xsi#”type”: “ns01:CustomRecordSearchAdvanced” , savedSearchId:<NETSUITE_INTERNAL_ID>): null
}
}
` NOTE: NetSuite has a unique internal Id for each and every record or even lists.
- Since NetSuite returns output in xml format, just put a transform message and convert it to application/json format. The search mule application is shown below:
2. GET LIST OPERATION:
- For this operation, also follow the steps as mentioned above, and in the connector, select the Ref type as RecordRef and Type as customList.
NOTE: The list that we are searching is a custom list that is created by the client.
- Now put the transform message before the connector, and you will see that the metadata is automatically populated as shown below:
DW PAYLOAD AFTER MAPPING:
%dw 2.0
output application/xml
ns ns0 urn:messages.platform.webservices.netsuite.com
ns ns01 urn:customization.setup.webservices.netsuite.com
ns ns02 urn:core.platform.webservices.netsuite.com
ns xsi http://www.w3.org/2001/XMLSchema-instance
ns ns03 urn:common.platform.webservices.netsuite.com
—
{
ns0#getList: {
ns02#baseRef @(internalId: <NETSUITE_INTERNAL_ID>,”type”: “customList”): null
}
}
3. UPDATE OPERATION:
- Drag down the NetSuite Update connector from the mule palette and do the configuration as shown above.
- In the general section of the connector choose the Type as CustomRecord(you may select according to your requirement).
- Now drag a transform message before the NetSuite update connector to load the metadata.
- Click on the fields that are required. (Here, we required recType as well as customFieldList).
- To know the exact input payload, you can either refer to the soap request payload or the one which we have used below:
SOAP REQUEST THAT WE REFERRED
DW PAYLOAD AFTER MAPPING:
%dw 2.0
output application/xml
ns ns0 urn:messages.platform.webservices.netsuite.com
ns ns01 urn:customization.setup.webservices.netsuite.com
ns ns02 urn:core.platform.webservices.netsuite.com
ns xsi http://www.w3.org/2001/XMLSchema-instance
—
{
ns0#update: {
ns0#record @(“xmlns:ns01”: ns01, internalId: <NETSUITE_RECORD_INTERNAL_ID>, xsi#”type”: “ns01:CustomRecord”): {
ns01#recType @(internalId: <NETSUITE_RECORD_TYPE_INTERNAL_ID>): <NETSUITE_RECORD_TYPE_INTERNAL_ID>,
ns01#customFieldList: {
ns02#customField @(xsi#”type”: “ns02:StringCustomFieldRef”, scriptId: “<NETSUITE_RECORD_NAME>”): {
ns02#value: <NETSUITE_VALUE_INTERNAL_ID>
}
}
}
}
}
` NOTE: NetSuite has a unique internal Id for each and every record or even lists.
- NETSUITE_RECORD_INTERNAL_ID : This is the internal id for the unique row in NetSuite.
- NETSUITE_RECORD_TYPE_INTERNAL_ID: This is the record type internal ID for uniquely identifying a particular record type. Here, we are viewing the Tracking List.
- NETSUITE_RECORD_NAME: When you click on any of the field names, ex: Tracking Number, you will see a field id which is nothing but scriptId only. This is the Custom Field for your account.
- NETSUITE_VALUE_INTERNAL_ID: This is the new value that you want to update to a particular field.
- Since NetSuite returns output in xml format, just put a transform message and convert it to application/json format. The updated mule application is shown below: