Return a Simple XML Document
Note:
This script sample uses the define
function, which is required for an entry point script (a script you attach to a script record and deploy). You must use the require
function if you want to copy the script into the SuiteScript Debugger and test it. For more information, see SuiteScript 2.x Global Objects.
The following sample creates a Suitelet that returns a simple XML document. For information about executing Suitelet scripts, see SuiteScript 2.x Suitelet Script Reference.
/**
* @NApiVersion 2.x
* @NScriptType Suitelet
*/
define([], function() {
function onRequest(context) {
var xml = '<?xml version="1.0" encoding="utf-8" ?>'+
'<message>'+'Hello World'+'</message>';
context.response.write(xml);
context.response.setHeader({
name: 'Custom-Header-Demo',
value: 'Demo'
});
}
return {
onRequest: onRequest
};
});
The following screenshot shows the output of this script.
