10

I am running into the issue below when trying to edit a CUSTOMER record in NetSuite. The script I have created is very simple.

What could I possibly doing wrong with such a simplistic piece of code?

{"type":"error.SuiteScriptModuleLoaderError","name":"MODULE_DOES_NOT_EXIST","message":"Module does not exist: /SuiteScripts/BillingInfoUpdated.js","stack":[]}

SCRIPT:

define(['N/log'], function (log) {

    /**
     * User Event 2.0 example showing usage of the Submit events
     *
     * @NApiVersion 2.x
     * @NModuleScope SameAccount
     * @NScriptType UserEventScript
     * @appliedtorecord customer
     */
    var exports = {};

    function afterSubmit(scriptContext) {
        log.debug({
            "title": "After Submit",
            "details": "action=" + scriptContext.type
        });
    }

    exports.afterSubmit = afterSubmit;
    return exports;
});
Panda
  • 6,955
  • 6
  • 40
  • 55
Coova
  • 1,818
  • 5
  • 36
  • 63

3 Answers3

24

Add .js to the end of the script file name

Nathan Sutherland
  • 1,191
  • 7
  • 9
  • 2
    Yes thank you! OP, please accept this answer. Definitely the correct one. – The Windhover Jan 29 '18 at 21:30
  • in my case i was using a naming convention for the file of `tla_target.type.js`. this worked fine until i got to scheduledscript which ended up as `tla_so.ss.js` I don't know why SuiteScript hiccups on the combo of `ss.js` but it does. perhaps `ss` is reserved for someone's dream of having a suitescript extension -- or perhaps `.ss` is a valid final extension treated like `.js` within their AMD config (didn't actually try). either way i used `sc` instead ( `tla_target.sc.js` ) and all was well – gillyspy Apr 01 '22 at 14:53
4

Nathan Sutherland answer worked for me and it's absolutely fine But I'm writing this answer so new user get that faster and not confused with other names. You need to add .js where the blue arrow points.

On starting while creating script. here

if you forget then edit here

NS

Avinash Singh
  • 4,970
  • 8
  • 20
  • 35
0

Use this instead:

var LOGMODULE; //Log module is preloaded, so this is optional

/**
 *@NApiVersion 2.x
 *@NModuleScope Public
 *@NScriptType UserEventScript
 */
define(['N/log'], runUserEvent);

function runUserEvent(log) {
    LOGMODULE = log;

    var returnObj = {};
    returnObj.afterSubmit = afterSubmit;
    return returnObj;
}

function afterSubmit(context) {
    log.debug('After Submit', "action=" + context.type);
    //LOGMODULE.debug('After Submit', "action=" + context.type); //Alternatively
    //context.newRecord; //Just showing how to access the records
    //context.oldRecord;
    //context.type;
    return;
}

For more 2.0 Quickstart Samples: ursuscode.com

Adolfo Garza
  • 2,966
  • 12
  • 15
  • This did not work, I get the same error. I am not sure if it is because I am trying to use SuiteScript 2.0? All other scripts in NetSuite 1.0, so if I have to enable the use of 2.0, then that could be it. – Coova Mar 22 '17 at 20:58
  • One weird thing is error says that the module is located at "/SuiteScripts/BillingInfoUpdated.js", I wonder if you are loading a library file in the script settings. Otherwise yeah, make sure you can run 2.0 code. You would know because when you upload the file Netsuite should recognize it as 2.0 and autopopulate the function name. – Adolfo Garza Mar 22 '17 at 21:00
  • It does recognize 2.0 code, and it does recognize the afterSubmit function. That directory is just the standard place where the script is located. I didn't do anything special lol. – Coova Mar 22 '17 at 21:03
  • Yeah, but is the name of your file "BillingInfoUpdated.js" ? – Adolfo Garza Mar 22 '17 at 21:04
  • 1
    Wait, I have had this problem before. Delete the script and the file. Create the script again and reupload the file, but this time make sure your filename ends with .js. This happened to me when I updated a file with no .js extension. – Adolfo Garza Mar 22 '17 at 21:05
  • 1
    This worked. I don't know why, but if you create the script by just selecting the .js file, it creates a file without the .js appended to its File Name. – Coova Mar 22 '17 at 21:23