ALERT IN NETSUITE USING USER EVENT BEFORE LOAD SCRIPT

HOW TO THROW ALERT FROM USER EVENT BEFORE LOAD SCRIPT?



It is a well known fact that alert can be thrown from client script by directly using alert() method. But lot of times developer needs to use user event script as client script has several limitations like not being able to run as admin. It always runs the script using the logged in user's role. Client script also doesn't get triggered when you view a record. It gets triggered only on edit, create and copy.

Alert can be thrown from user event script by using a mix of  html code with Netsuite API. So, first you will to create a custom field of type inline html. Label is not required for this field. This field can be created using form object in the before load function.

Then we can set an html alert in that field as default value. The code snippet is given below


function UE_BeforeLoad(type, form, request)

{


            var alert_value = "<html><body><script type='text/javascript'>window.alert('HELLO..UE ALERT')</script></body></html>";
    
            var field = form.addField('custpage_alertfield' ,  'inlinehtml');
    
    
            field.setDefaultValue(alert_value);
    
     
}

contact us at:
Email : info@smilingcoders.com

Comments

Popular posts from this blog

Work Around the 1000 Row Limit Returned by Saved Searches in Netsuite

USING CASE (IF AND ELSE) IN NETSUITE SAVED SEARCH- NETSUITE ACADEMY

HOW TO SET SUBLIST SUB RECORD VALUES IN SUITE SCRIPT 1.0 AND 2.0