Hello, Can anyone help me to understand if it is possible to render a html file in suitelet 2.0?
s
sayyad
01/16/2019, 12:31 PM
use the N/render module
sayyad
01/16/2019, 12:31 PM
steps to render HTML:
step 1: create render object var renderer = render.create();
sayyad
01/16/2019, 12:32 PM
step 2: to that add the html file content renderer.templateContent = xmlTemplateFile.getContents();
sayyad
01/16/2019, 12:33 PM
step 3: var templateString = renderer.renderAsString(); it will return as string
sayyad
01/16/2019, 12:35 PM
step 4: use response.write(templateString)
s
samyt
01/16/2019, 1:18 PM
But how can I pass the data from suitelet to html ? @sayyad
s
sayyad
01/16/2019, 1:55 PM
which type of data you want to pass in html? is it record, search result or custom data? @samyt
sayyad
01/16/2019, 1:56 PM
These three can be achieved in 3 different ways
TemplateRenderer.addCustomDataSource(options)TemplateRenderer.addRecord(options)TemplateRenderer.addSearchResults(options)