HOW TO RETURN A VALUE FROM A BACKEND SUITELET TO CLIENT SCRIPT?
Category : suitescript
You can use nlapirequesturl to call backend suitelet and from suitelet after searching the values, write it back using response.write(values) where values is any variable. See the code below for more detail fo:r netsuite support
client script:
var loc_id = nlapiGetFieldValue(‘location’);
var suiteletUrl = nlapiResolveURL(‘SUITELET’, ‘scriptid’, ‘script deployment id’); //Get the Suitelet URL
var response = nlapiRequestURL(suiteletUrl+ ‘&loc_id=’ +loc_id);
if(response.getBody())
{
var address = response.getBody();
nlapiSetFieldValue(‘custpage_address’, address);
}
suitelet script:
var loc_id = request.getParameter(‘loc_id’);
if(loc_id)
{
var load_loc = nlapiLoadRecord(‘location’, loc_id );
var addrs = load_loc.getFieldValue(‘addrtext’);
response.write(addrs);
}
Feel free to reach out TheSmilingCoders for proper netsuite implementation, netsuite consultation , netsuite customization, netsuite Support,netsuite Training contact us at:
Email : [email protected]
Linkedin : https://www.linkedin.com/company/netsuite-academy/