• : 1-877-596-8218
  • : sales@aecc.ca
# # #

RESTLet Part 3 — the POST Request

In NetSuite you can write a POST Request function. The only difference between NS GET and POST request is that the GET request passing values in its URI, however, POST request can pass an object body with the POST call. It’s the best practice to use GET request to get required data from NS and use POST request when making any update or modifications in NS.

Let’s start making a simple POST RestLet for NS.

We want to update a custom body field which the internal ID is “custentity_login_psd” on the employee record in NS. An email address stored in a custom body field called “custentity_login_email” will be used to locate the employee record.

We start the POST function by a saved search to find the internal ID of the employee record, then we load this employee record using its internal ID and make some changes on this record.

function postResetPsd(datain) {
	try {
		var email = datain.email;
		var newPsd = datain.newPsd;

		//define the saved search criteria and columns
		var filters = [];
		var columns = [];
		filters.push(new nlobjSearchFilter('custentity_login_email', null, 'is', email));
		filters.push(new nlobjSearchFilter('isinactive', null, 'is', false));
		columns.push(new nlobjSearchColumn('internalid'));
		try {
			var result = savedSearch('employee', filters, columns);
		} catch (searchEmployeeError) {
			nlapiLogExecution('debug', searchEmployeeError.toString());

		if (!isEmpty(result)) {
			//only one employee record can have the same email address 
			if (result.length == 1) {
				var recordID = result[0].getValue('internalid');
				nlapiSubmitField('employee', recordID, 'custentity_login_psd', newPsd);
				return "Password has been changed";

			} else {
				return "more than one employee have the same login email";
		} else {
			//if no employee has this email, return text
			return "Login email wrong";

	} catch(postResetPsdError) {
		nlapiLogExecution('debug', postResetPsdError.toString());


We’re passing two variables into this POST function, the email address to location a specific employee record and the “newPSD” to update the password field.

After this script deployed into NS, we can make our POST call using PostMan.
Not like GET Request, the POST request passing its arguments in a body object.

We’re passing two variables in the body into the POST request. As shown above.
This POST RestLet will return the status of this POST request depending on the results of the action.