Friday, September 21, 2018

Render HTML Markup on a Suitelet from an HTML File on the File Cabinet

A user would like to create his own form/html page using a suitelet. While there is a way to do this by concatenating a string that represents html markup, it is difficult to implement. The user would like to upload an HTML file onto the File Cabinet and then render it onto a suitelet.

To do this, create an HTML file and upload it to the File Cabinet. Load the File using nlapiLoadFile and then get its contents. The last step would be is to render it onto a suitelet using the write method of the nlobjResponse object. Below is a sample code: 

function renderHTMLFromFile(request, response) {
 if(request.getMethod() == 'GET') {
  var file = nlapiLoadFile(350);
//load the HTML file
  var contents = file.getValue(); //get the contents
  response.write(contents); 
//render it on the suitelet
 }
}

No comments:

Post a Comment