RE: Why does my suitelet return a login page as response?
I have a workflow action script that should call a suitelet and fetch response. The suitelet should actually return some custom html code, but instead it returns me Netsuite Login Page as a response.
Call from workflow action script:
/**
* @NApiVersion 2.1
* @NScriptType WorkflowActionScript
*/
define(['N/redirect','N/ui/dialog','N/http','N/url','N/runtime'],
(redirect,dialog,http,url,runtime) => {
const onAction = (scriptContext) => {
var domain = url.resolveDomain({
hostType: url.HostType.APPLICATION
});
var scriptURL = url.resolveScript({
scriptId: 'customscriptor_st_triggersuitelet',
deploymentId: 'customdeployor_st_triggersuitelet',
returnExternalURL: true
});
var results=http.get({
url: "http://" +domain+scriptURL
})
log.debug("Result is",results);
}
return {onAction};
});
My suitelet code:
/**
* @NApiVersion 2.1
* @NScriptType Suitelet
*/
define(['N/ui/serverWidget','N/runtime','N/ui/dialog'],
(serverWidget,runtime,dialog) => {
const onRequest = (scriptContext) => {
var html = '<html>' +
'<body>something: <br/>'
+'<form method="post">' +
' Input ' +
'<input type="text" name="something" id="something" value=""/> ' +
'<input type="submit"/> ' +
'</form></body></html>';
scriptContext.response.write(html);
}
return {onRequest}
});
The response l receive from the suitelet :
<!doctype html>\n\n<html>\n<head>\n\t<title>NetSuite Login</title>\n\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n> ....(contd)
Any idea on what is the issue?