Restlet using NLAUTH in NetSuite

Restlet using NLAUTH in NetSuite

In this tutorial of smiling coders we are going to share you how to write your first Restlet script.

You can see this is the restlet with get function having record type and record id on record load and context is passing it to function. Restlet has 2 url one external and one internal. The restlet script shown here will return you the record data in response. Here we are using customer record with id 449 and passing in the restlet url.

In below piece of code you can see we have a get function which is returning a record type to the response. For this demo we are using a postman to hit the URL

In the postman we are selecting a get function and pasting a script external url for accessing an external url we need an authentication mechanism. The Authentication is required for login into the netsuite from an external system and the netsuite will validate the request and return the response.

Authentication mechanism we are using is NL auth where email, password and accound id is required.

Then we hit the url and analyze the response.

You can see the customer record info in the response.

To retrieve a record by using this RESTlet, we use the get method. To identify the record we want to retrieve, we would add values to the URL you use to call the RESTlet. These values would identify the record type and internal ID of the record instance you want. These parameters are defined in the RESTlet’s get function as:

Recordtype :  Customer

Id: 449

You add a value for each parameter by using an ampersand, the name of the parameter, an equals sign, and the parameter’s value, as follows:

&[name of parameter]=[value]

authorization: NLAuth nlauth_account=12345, [email protected], nlauth_signature=Welcome123

/**

 *@NApiVersion 2.x

 *@NScriptType Restlet

 */

define([‘N/record’], function (record) {

    function _get(context) {

          return JSON.stringify(record.load({

              type: context.recordtype,

              id: context.id

          }));

    }

    return {

        get: _get,

    }

});

Feel free to reach out Netsuite Solution provider  TheSmilingCoders for proper netsuite implementationnetsuite consultation , netsuite customizationnetsuite Supportnetsuite Training NetSuite Celigo Integration , Celigo ConsultantCeligo Integration Consultant.

contact us : [email protected]

Facebook : https://www.facebook.com/Smiling-Coders-Netsuite-Training-Implementation-and-Support-1591053827660082/

Linkedin : https://www.linkedin.com/company/netsuite-academy/