Is it possible to use the N/ui/message module to d...
# suitescript
t
Is it possible to use the N/ui/message module to display a message in View mode?
j
Yes. But you need a userevent script to load the client script. It's a little funky.
t
Thanks @jarens, I'll give it a shot
I know I can attach a client script to a form, but how would I call a client script in a UE script?
j
Copy code
/**
 *@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
        };
    });
t
Interesting - thanks!