netsuitesuitescriptsuite

"define" is not defined when executing suite script 2.0 user event


I'm trying to execute the suite script2.0 user event

/**
 *@NApiVersion 2.0
 *@NScriptType UserEventScript
 */
define(["N/record"], function (r) {
    function onAfterSubmit(context) {
}})

but while uploading the js file in net enter image description heresuite It's not allowing to upload the 2.0 js file

i'm getting define no defined error..

thanks in Advance!


Solution

  • Your code isn't being recognized as SS2. You need a space between the * and the @N... in the JSDoc

    /**
     * @NApiVersion 2.x
     * @NScriptType UserEventScript
     * @NModuleScope SameAccount
     */
    define(['N/record'],
        function(r){
    
    
            function onAfterSubmit(context){
    
                log.debug('After Submit Triggered');
    
            }
    
        return {
        afterSubmit: onAfterSubmit
    };
    

    });