What is the correct syntax for accessing a Suitlet Parameter as part of the response?

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?

Beginner Asked on October 9, 2019 in SuiteScript.
Add Comment
1 Answer(s)
Best answer

Bad example. Use context.request.parameters.custpage_itemfield

Advanced Answered on October 9, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor   Become a Sponsor