mtoniato
09/05/2023, 10:29 AMmtoniato
09/05/2023, 10:44 AMNetsuite Tragic
09/05/2023, 11:09 AMvar myMsg = message.create({
title : 'Return Failed',
message : 'Review Related Records for RA & Item Receipts. You will need to manually enter for this Return.',
type : message.Type.WARNING
})
//display message
context.form.addPageInitMessage({
message : myMsg,
duration : 50000
});
mtoniato
09/05/2023, 11:09 AMmtoniato
09/05/2023, 11:09 AMmtoniato
09/05/2023, 11:09 AMNElliott
09/05/2023, 11:23 AMmtoniato
09/05/2023, 11:24 AMNElliott
09/05/2023, 11:25 AMmtoniato
09/05/2023, 11:26 AMmtoniato
09/05/2023, 4:31 PMconst beforeLoad = (scriptContext) => {
let current_session = runtime.getCurrentSession();
if(scriptContext.newRecord.id){
overallocation_message = current_session.get({name: "overallocation_message_"+scriptContext.newRecord.id});
if(overallocation_message){
scriptContext.form.addPageInitMessage({
title: "Over Allocations",
message: overallocation_message,
type: message.Type.ERROR
});
current_session.set({name: "overallocation_message_"+scriptContext.newRecord.id, value: null});
}
}
scriptContext.form.clientScriptModulePath = "/SuiteScripts/ResourceCalendar/aly_resource_plan_show_error_cs.js";
}
I added a Client Script that uses the window.opener and the unload event.
define(['N/currentRecord'],
/**
* @param{runtime} runtime
* @param{message} message
*/
function(currentRecord) {
window.addEventListener("unload", (e) => {
var task = currentRecord.get();
alert("TASK "+task.id);
window.opener.require(['N/ui/message', 'N/runtime'], (message, runtime) => {
let current_session = runtime.getCurrentSession();
var overallocation_message = current_session.get({name: "overallocation_message_"+task.id});
if(overallocation_message){
var error_message=message.create({
title: "Over Allocations",
message: overallocation_message,
type: message.Type.ERROR
});
error_message.show();
current_session.set({name: "overallocation_message_"+task.id, value: ""});
}
});
return true;
});
});
In this way when the Project Task popup is closed, the project page is updated without reloading.