Boris
09/19/2025, 2:13 PMCeligo AI
09/19/2025, 2:14 PMAI generated answer (using internal Slack threads):Yes, you can show a UI message in a User Event script before the load event. However, it requires a combination of User Event and Client scripts. In your User Event script's
beforeLoad()
function, you can include a Client Script using the following code:
javascript
if(runtime.executionContext == runtime.ContextType.USER_INTERFACE)
context.form.clientScriptModulePath = ‘path/to/your/client/script’;
Then, in your Client Script, you can adjust the content of the HTML field. You can make the default value of the inlineHTML something like <div id="fill_this_in_on_page_load"></div>
, and then your client script would have something like jQuery('#fill_this_in_on_page_load').html('here is my fancy HTML');
.
Here is an example of how you can call a client script in a User Event script:
javascript
/**
*@NApiVersion 2.x
*@NScriptType UserEventScript
*/
define(['N/record', 'N/ui/serverWidget'],
function (record, ui) {
function beforeLoad(context) {
try {
if (context.type != 'view') return;
var inline = context.form.addField({
id: 'custpage_trigger_it',
label: 'not shown',
type: ui.FieldType.INLINEHTML,
});
inline.defaultValue = "<script>jQuery(function($){ require(['/SuiteScripts/SampleScriptName'], function(mod){ console.log('loaded'); mod.showMessage();});});</script>";
} catch (e) {
}
}
return {
beforeLoad: beforeLoad
};
});
Please note that setting values is only allowed in beforeLoad
when the record is created. setValue
is ignored when editing a record in beforeLoad
. If you need to set a value when the page is loaded, you can use a Client Script with the pageinit
function.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
09/19/2025, 2:14 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.862609863
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.859496951
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.848144531
Celigo AI
09/19/2025, 2:14 PM