User event script
/**
 * @NApiVersion 2.1
 * @NScriptType UserEventScript
 */
define(['N/ui/message','N/runtime','N/email'],
      (message,runtime,email) => {
          /**
           * Defines the function definition that is executed before record is loaded.
           * @param {Object} scriptContext
           * @param {Record} scriptContext.newRecord - New record
           * @param {string} scriptContext.type - Trigger type; use values from the context.UserEventType enum
           * @param {Form} scriptContext.form - Current form
           * @param {ServletRequest} scriptContext.request - HTTP request information sent from the browser for a client action only.
           * @since 2015.2
           */
          let imageTag = '<img width="50px" height="50px" src="https://static3.depositphotos.com/1002188/144/i/600/depositphotos_1448005-stock-photo-smile.jpg"/>'
        const beforeLoad = (scriptContext) => {
              try {
                //Shows a smilie on before load
            scriptContext.form.addPageInitMessage({
                  type: message.Type.CONFIRMATION,
                  message: imageTag,
                  title:'Hi '+runtime.getCurrentUser().name
                  //,duration: 5000
                });
              }catch(err)
              {
                log.debug("error@beforeLoad",err)
              }
          }
          /**
           * Defines the function definition that is executed before record is submitted.
           * @param {Object} scriptContext
           * @param {Record} scriptContext.newRecord - New record
           * @param {Record} scriptContext.oldRecord - Old record
           * @param {string} scriptContext.type - Trigger type; use values from the context.UserEventType enum
           * @since 2015.2
           */
          const beforeSubmit = (scriptContext) => {
            try {
              //Sends a message in before submit
              email.send({
                subject: 'You sales order notification - beforeSubmit',
                author: runtime.getCurrentUser().id,
                recipients: [runtime.getCurrentUser().id],
                body: "Hi " + runtime.getCurrentUser().name + '<br/>' + imageTag + '<br/> This email triggered before your SO is commited to the Netsuite Data base<br/>'
              })
            }catch(err)
            {
              log.debug("error@beforeSubmit",err)
            }
          }
          /**
           * Defines the function definition that is executed after record is submitted.
           * @param {Object} scriptContext
           * @param {Record} scriptContext.newRecord - New record
           * @param {Record} scriptContext.oldRecord - Old record
           * @param {string} scriptContext.type - Trigger type; use values from the context.UserEventType enum
           * @since 2015.2
           */
          const afterSubmit = (scriptContext) => {
            try {
              //Sends a message in after submit
              email.send({
                subject: 'You sales order notification- afterSubmit',
                author: runtime.getCurrentUser().id,
                recipients: [runtime.getCurrentUser().id],
                body: "Hi " + runtime.getCurrentUser().name + '<br/>' + imageTag + '<br/> This email triggered after your SO is commited to the Netsuite Data base<br/>'
              })
            }catch(err)
            {
              log.debug("error@afterSubmit",err)
            }
          }
          return {beforeLoad,beforeSubmit, afterSubmit}
      });
XML
<usereventscript scriptid="customscript_sample_userevent">
<description></description>
<isinactive>F</isinactive>
<name>Sample User event</name>
<notifyadmins>F</notifyadmins>
<notifyemails></notifyemails>
<notifyowner>T</notifyowner>
<notifyuser>F</notifyuser>
<scriptfile>[/SuiteScripts/Sample Script/Sample - UserEvent.js]</scriptfile>
<scriptdeployments>
<scriptdeployment scriptid="customdeploy_sample_userevent">
<allemployees>F</allemployees>
<alllocalizationcontexts>T</alllocalizationcontexts>
<allpartners>F</allpartners>
<allroles>T</allroles>
<audslctrole></audslctrole>
<eventtype></eventtype>
<executioncontext>USERINTERFACE</executioncontext>
<isdeployed>T</isdeployed>
<loglevel>DEBUG</loglevel>
<recordtype>SALESORDER</recordtype>
<runasrole></runasrole>
<status>RELEASED</status>
</scriptdeployment>
</scriptdeployments>
</usereventscript>