To add a warning message to a user event script, you can use the N/ui/message module in SuiteScript which provides a way to create different types of messages (e.g., warning, confirmation, error) and display them on the form. Below is an example code snippet showing how to create a warning message within a user event script.
displaySuccessMessage{
try {
let form=scriptContext.form
let confirMessage = message.create({
title: "TITLE",
message: "MESSAGE",
type: message.Type.CONFIRMATION
});
// Add the message to the form as a field
form.addPageInitMessage({
message: confirMessage
});
}
catch (e) {
log.error("Error @ displaySuccessMessage", e);
}
}