<@U5TNEF7FW> I have this method/page that allows m...
# suitescript
s
@karlenigma I have this method/page that allows me to reuse this whenever I want it. Here is the page that shows the display message
Copy code
define(['N/ui/message', 'N/currentRecord'], function (msg, currentRecord) {
    // window.console.log('processing script');
    /**
     * This will show the message informing the user that they do not have the ability to edit this record
     * @param title Title of message.
     * @param statusText message to display.
     * @param type the type of message to display.
     var title = "Cannot Edit";
     */
    function showMessage(title, statusText, type)
    {
        //show the netsuite message.
        msg.create({
            title: title,
            message: statusText,
            type: type
        }).show()
        // .show({duration: 10000});
    }

    return {
        showMessage: showMessage
    };
});
Here is the method that calls the page
Copy code
function showMessage(context, title, message, type)
{
	var request = context.request;
	var form = context.form;
	if (request.parameters["readonly"])
	{
		require(["N/ui/serverWidget"], function (serverWidget)
		{
			//adds a hidden inline html field that will force it to show a client side message IF they've been redirected.
			var inline = form.addField({
				id: 'custpage_trigger_it',
				label: 'not shown',
				type: serverWidget.FieldType.INLINEHTML
			});
			//This will call the showMessage method in the osm_display_readonly_message.js;
			inline.defaultValue = "<script>jQuery(function($){require(['/SuiteScripts/Main/Source/NetSuite/Libs/osm_view_clientscript_file']," +
				" function(mod){mod.showMessage('" + title + "','" + message + "','" + type + "');});})</script>";
		});
	}
}
This is where I call the method, from a UserEvent script, that will display my message on view. cHelper is a custom module/lib I placed the showMethod in.
Copy code
var title = "Cannot Edit";
var message = "The Transfer Order has been processed. Changes are no longer allowed";
var type = "WARNING";
cHelper.showMessage(context, title, message, type);