function onRequest(scriptContext) {
if (scriptContext.request.method === ‘GET’) {
try {
let processTaskTrigger = task.create({
taskType: task.TaskType.MAP_REDUCE,
scriptId: ‘script id’,
deploymentId: ‘deployment id’,
params: {}
});
processTaskTrigger.submit();
let form = serverWidget.createForm({
title: ‘Order Sync AMP to NetSuite’
});
form.addSubmitButton({
label: ‘Submit’
});
// Write client script to handle the popup display
let clientScript = “<script>”;
clientScript += “require([‘N/ui/dialog’], function(dialog){“;
clientScript += “dialog.confirm({“;
clientScript += “title: ‘Manual Order sync Initiated’,”;
clientScript += “message: ‘The Order manual order sync has been initiated and refer to the status page for more information.'”;
clientScript += “}).then(window.location.href = ‘https://{add url details}’);”;
clientScript += “});”;
clientScript += “</script>”;
// Add the client script to the form
form.addField({
id: ‘custpage_client_script’,
type: serverWidget.FieldType.INLINEHTML,
label: ‘Client Script’
}).defaultValue = clientScript;
// Write the form to the response
scriptContext.response.writePage(form);
} catch (err) {
log.error(“err @ calling map/reduce”, err)
}
}
}