RE: What is the correct syntax for accessing a Suitlet Parameter as part of the response?
Answered
The documentation on N/serverWidget is incorrect or misleading.
/app/help/helpcenter.nl?fid=section_4321345532.html
My attempt to implement a simple Suitelet with one field.
function onRequest(context){
if(context.request.method === 'GET') {
var form = serverWidget.createForm({
title: "Item Look Up"
});
var itemField = form.addField({
id: 'custpage_itemfield',
type: serverWidget.FieldType.TEXT,
label: 'Item'
});
form.addSubmitButton({
label: 'Submit;
});
context.response.writePage(form);
} else {
var itemParameter = context.request.paramters.itemfield;
// Following the NetSuite Documentation
log.debug("itemParameter", itemParameter);
context.response.write(itemParameter);
}
}
The Logs show nothing for itemParameter. But if I were to log the full parameters,
log.debug(“context.response.parameters”, JSON.stringify(context.request.parameters));
I clearly see, ‘custpage_itemfield’ with the correct value.
Is the Documentation incorrect? Should I access itemfield using
context.request.parameters.custpage_itemfield
instead?
Best answer
Bad example. Use context.request.parameters.custpage_itemfield