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.

          /**
 * @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.

Sample script that returns a simple XML document output is xml header with Hello World as the message.

Related Topics

SuiteScript 2.x Suitelet Script Type
SuiteScript 2.x Suitelet Script Type Code Samples
Create a Survey

General Notices