NETSUITE TUTORIALS

netsuite tips & tricks

Some points on design a RESTlet in effective way for Beginners & Intermediate

RESTlet is a script type where it is used for read/create/update records in NetSuite. It takes JSON string as input data and processes the required action in the NetSuite system.

How a requirement of RESTlet will be ?
The requirement is straight forward from the customer where they require a module that should read/update/create record when it is externally call by a another program or manually and also the requirement need the RESTlet is enough to work for specific record types. But later days the customer may expect the RESTlet to work for other record types too. In that case we should have a proper design on RESTlet script that should need a minimal change of code to achieve the customer requirement.

Proper Design means ?
The RESTlet should be generic upto a level. For example, A RESTlet that creates a customer record should also perform creation of Employee records. Yes, this is what i try to mean with the term GENERIC. Most of the new developers may have question, How it will be possible ? How we handle the field names ? How we handle the Record types ?. That is where the thought process needed.

Lets come to the implementation of GENERIC RESTlet. Following things are key list to make a GENERIC RESTlet
1. No fieldname is to be hardcoded in script unless it is essential
2. RESTlet mandatory parameter on the input JSON should be recordtype & internalid
3. RESTlet must check either the received JSON string is for create or update
4. RESTlet must have the feature to handle single and multi records in a call
5. Log information is essential on RESTlet to track the records that are processed.
6. RESTlet must be designed with custom error codes
7. RESTlet must be work even after a error on any one of the records. i.e., it should process all success records and skip the error one and have to give the details back to the calling function with details
8. All among this, the everything that is implemented, behaviour, the input JSON format, custom error code & messages

Published by

Leave a comment