Sim Greenbaum
02/05/2024, 6:27 PMif (method == "POST") {
syncData(params);
} else {
widget(options);
}
function syncData(params) {
let type = params.selectfield;
//// post take data from post params and get url form url and display response
let syncData = railsSync.getSyncObject(type, mainUrl);
var form = serverWidget.createForm({
title: syncData.title,
hideNavBar: false,
});
var orderid = form.addField({
id: "orderid",
type: serverWidget.FieldType.INLINEHTML,
label: "API Response",
});........
var infoHTML =
"<div class='info-container'>" +
`<p style=color:${worker_status.color}><strong>API Code :</strong> ` +
worker_status.code +
"</p>" +
`<p style=color:${worker_status.color}><strong>Response:</strong> ` +
worker_status.body +
"</p>" +
"</div>" +
`<style>.info-container {
font-size: 20px;
}</style > `;
orderid.defaultValue = infoHTML;
options.response.writePage(form);
Nathan L
02/05/2024, 6:42 PMNathan L
02/05/2024, 6:45 PMSim Greenbaum
02/05/2024, 7:03 PMSim Greenbaum
02/05/2024, 7:49 PMform.addButton({
id: "custom_refresh_button",
label: "Refresh",
functionName: "refreshPage",
});
Nathan L
02/05/2024, 7:52 PMNathan L
02/05/2024, 7:52 PMfunction reloadPageWithParams(paramsObj) {
try {
// get current url
const currentUrl = document.location.href;
// clear out any existing parameters from the url
let url = currentUrl.split('?')[0] + '?';
url += currentUrl.split('?')[1].split('&')[0] + '&' + currentUrl.split('&')[1] + '&';
// add new parameters to the url
Object.keys(paramsObj).forEach((param) => {
url += `${param}=${paramsObj[param]}&`;
});
// stop page from asking to reload
window.onbeforeunload = null;
// reload page with url + params
window.location.replace(url);
} catch (e) {
console.log(e);
}
}
Nathan L
02/05/2024, 7:52 PMreptar
02/05/2024, 10:13 PMreptar
02/05/2024, 10:13 PMreptar
02/05/2024, 10:16 PMreptar
02/05/2024, 10:16 PMSim Greenbaum
02/05/2024, 10:23 PMreptar
02/05/2024, 10:33 PMSim Greenbaum
02/05/2024, 10:35 PMvar orderid = form.addField({
id: "orderid",
type: serverWidget.FieldType.INLINEHTML,
label: "API Response",
});
var infoHTML =
"<div class='info-container'>" +
`<p style=color:${worker_status.color}><strong>API Code :</strong> ` +
worker_status.code +
"</p>" +
`<p style=color:${worker_status.color}><strong>Response:</strong> ` +
worker_status.body +
"</p>" +
"</div>" +
`<button type="button" id="refreshButton" style="background-color: blue; color: white;">Refresh</button>
<style>.info-container {
font-size: 20px;
}</style ><script>
// Adding a click event listener to the button
document.getElementById('refreshButton').addEventListener('click', function() {
window.location.href = ${href};
console.log(${href});
});
</script>
orderid.defaultValue = infoHTML
Sim Greenbaum
02/05/2024, 10:35 PMreptar
02/05/2024, 10:37 PMSim Greenbaum
02/05/2024, 10:38 PMSim Greenbaum
02/05/2024, 10:50 PMSim Greenbaum
02/05/2024, 10:51 PMform.clientScriptModulePath = "../clientRefresh.js";
form.addButton({
id: "custom_refresh_button",
label: "Refresh",
functionName: "refreshPage()",
});
reptar
02/05/2024, 10:55 PM@NApiVersion
)Sim Greenbaum
02/05/2024, 10:55 PM/**
* @NApiVersion 2.1
* @NScriptType Suitelet
*/
reptar
02/05/2024, 10:56 PMSim Greenbaum
02/05/2024, 10:56 PMSim Greenbaum
02/07/2024, 10:55 PMreptar
02/07/2024, 10:57 PMsomeVar
is a string.reptar
02/07/2024, 10:59 PMfunctionName
as an entry point function in your client script. Accept a named variable in that function.reptar
02/07/2024, 11:00 PMSim Greenbaum
02/07/2024, 11:02 PMreptar
02/07/2024, 11:05 PMSim Greenbaum
02/07/2024, 11:08 PMhistory.back();
reptar
02/07/2024, 11:10 PMreptar
02/07/2024, 11:10 PMreptar
02/07/2024, 11:13 PMreptar
02/07/2024, 11:16 PMSim Greenbaum
02/07/2024, 11:16 PMform.clientScriptModulePath = "../clientRefresh.js";
form.addButton({
id: "custom_refresh_button",
label: "Refresh",
functionName: "refreshPage()",
});
reptar
02/07/2024, 11:17 PMreptar
02/07/2024, 11:18 PMconsole.log('test')
from the client scriptSim Greenbaum
02/07/2024, 11:21 PMSim Greenbaum
02/07/2024, 11:22 PMSim Greenbaum
02/07/2024, 11:26 PMUncaught SyntaxError: missing ) after argument list
reptar
02/08/2024, 2:41 PMreptar
02/08/2024, 3:00 PMSim Greenbaum
02/08/2024, 5:05 PMform.clientScriptModulePath = "../clientRefresh.js";
form.addButton({
id: "custom_refresh_button",
label: "Refresh",
functionName: "refreshPage(" + href + ")",
});
Sim Greenbaum
02/08/2024, 5:20 PM`refreshPage("${href}" )`,
reptar
02/08/2024, 5:57 PMSim Greenbaum
02/08/2024, 6:50 PM