7px
10/07/2022, 3:34 AM7px
10/07/2022, 3:34 AM<form method="post" action="<https://SuiteletHostedOnFileCabinet.js>">
<table>
<tbody><tr>
<td id="ttext">Test Text</td>
<td><input id="input1" placeholder="Anything" name="Input1" required="" type="text"></td>
</tr>
</tbody></table>
<br>
<button type="submit" class="btn" formmethod="post">Test Form</button>
<script>
//testing if the Suitelet value passed through
let queryString = window.location.search;
let urlParams = new URLSearchParams(queryString);
let id = urlParams.get('recid');
document.getElementById('input1').innerHTML = id;
</script>
</form>
Suitelet
/**
* @NApiVersion 2.1
* @NScriptType Suitelet
*/
define(['N/https', 'N/log'], function callbackFunction(https, log) {
function getFunction(context) {
//record ID was passed from a Client Script to the Suitelet
var id = parseInt(context.request.parameters.custom_id,10);
let headerObj = { name: 'recid', value: id };
var contentRequest = https.get({ url: "<https://HTML_hosted_on_File_Cabinet.html>", headers: headerObj });
var contentDocument = contentRequest.body;
context.response.write(contentDocument);
}
function postFunction(context) {
let test = Object.keys(context);
log.debug({ title:"Testing variable passthrough", details: test })
context.response.write(test);
}
function onRequestFxn(context) {
if (context.request.method === "GET") { getFunction(context) }
else { postFunction(context) }
}
return { onRequest: onRequestFxn };
});
battk
10/07/2022, 3:39 AMbattk
10/07/2022, 3:39 AMbattk
10/07/2022, 3:39 AMwbermudo
10/07/2022, 3:40 AMbattk
10/07/2022, 3:41 AMbattk
10/07/2022, 3:42 AM7px
10/07/2022, 3:57 AMbattk
10/07/2022, 4:06 AMbattk
10/07/2022, 4:06 AM