Modules
Objects/Functions
SuiteScript 2.0
{TemplateRenderer}.addCustomDataSource({alias: {string*},format: {render.DataSource*},data: {Object | Document | string*}})
N/render Module
TemplateRenderer.addCustomDataSource()
Method Description:
Adds XML or JSON as custom data source to an advanced PDF/HTML template
Returns:
Void
Supported Script Types:
Server-side scripts
For more information, see SuiteScript 2.0 Script Types.
Governance:
None
Module:
N/render Module
Since:
2016.1
Search NetSuite -
https://system.netsuite.com/app/help/helpcenter.nl?search=TemplateRenderer.addCustomDataSource(options)
Example:
// Code Example 1
//Add additional code
//...
var renderer = render.create();
var xmlObj = xml.Parser.fromString(xmlString);
var jsonObj = JSON.parse(jsonString);
renderer.templateContent = "${XML.book.title}
${XML.book.chapter[1].title}
${JSON.book.title}
${JSON.book.chapter[1].title}
${JSON_STR.book.title}
${XML_STR.book.title}";
renderer.addCustomDataSource({
format: render.DataSource.XML_DOC,
alias: "XML",
data: xmlObj
});
renderer.addCustomDataSource({
format: render.DataSource.XML_STRING,
alias: "XML_STR",
data: xmlString
});
renderer.addCustomDataSource({
format: render.DataSource.OBJECT,
alias: "JSON",
data: jsonObj
});
renderer.addCustomDataSource({
format: render.DataSource.JSON,
alias: "JSON_STR",
data: jsonString
});
var xml = renderer.renderAsString();
//...
//Add additional code
//SOURCE: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_4528541027.html