Netsuite Update Operation through MuleSoft — Part 3
In our last blog we have seen how to perform Insert Operation using NetSuite Connector in MuleSoft by inserting a Customer record as an example. In this blog we will see how to perform Update Operation using NetSuite Connector in MuleSoft by updating a Customer record as an example.
Business Use-Case:
Let’s assume that there is a record updated of the same or different record type such as Customer, Item, Order etc., at the source system (It can be a Database, Salesforce etc.,) which needs to be synchronized at NetSuite. MuleSoft’s NetSuite Update connector provides the facility to process the record and the same record will be updated in NetSuite.
Update Operation:
The update operation is used to update an instance of a record in NetSuite. Only the fields that have been populated in each submitted record are updated in the system. If a field has NOT been populated, it is not updated in the system and it retains its previous value. If a field is set to an empty string, the previous value of the field is replaced with an empty string. Therefore, when updating records, it is recommended that you get the desired record to ensure that only the fields requiring an update are written on submission. Lets demonstrate the Update operation with a sample POC.
In the update-customer-flow as shown in the screenshot, NetSuite Update Connector updates a customer record in the NetSuite system.
First, set up a HTTP Listener with a path and configure connection. and then add a NetSuite Update connector into the flow. In the Update connector, select the Type of the record as Customer and provide payload in the Message as shown in the below screenshot.
Then add a Transform message before the Update operation and metadata will be generated automatically as shown in the below screenshot.
Use a DataWeave transformation to map the input payload to the format required by the NetSuite Update connector. The mapping should include the InternalId and the fields to be updated. xsi schema needs to be defined in the code to make the operation work.
Here’s an example DataWeave mapping that updates the entityId, email and phone fields of a Customer record as shown in the below screenshot
And at the end of the flow add a Transform message and convert the output to JSON. Once the flow is triggered, NetSuite Update Connector will update the Customer record of the corresponding internalId.
Conclusion
In this blog, we have seen how to perform Update Operation using NetSuite connector in MuleSoft.