Not logged in - Login
< back

Calling a RESTlet from a SuiteLet

A RESTlet script in NetSuite is very much like a web service in a web application.

The following example illustrates how to call a RESTlet script from a SuiteLet script in NetSuite.

Note: The 'Redirect' module must be included in the script.

/**
 * @NApiVersion 2.0
 * @NScriptType UserEventScript
 */
define(['N/record', 'N/redirect'],
/**
 * @param {record} record
 * @param {redirect} redirect
 */
function(record, redirect) {
...
}

Calling the RESTlet:

redirect.toSuitelet({
   scriptId     : 'customscript_sdr_sl_update_emp_notes', // this is the script ID of the RESTlet
   deploymentId : 'customdeploy_sdr_sl_update_emp_notes', // this is the deployment ID of the RESTlet
   parameters   : { // these are the parameters 
       that are passed to the RESTlet, the names of which can be anything
      sdr_name  : employee.getValue('entityid'),
      sdr_notes : employee.getValue('comments'),
      sdr_empid : employee.id
   }
});