If you have a User Event Script that is giving you an error like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
{ 
    "type":"error.SuiteScriptError",
    "name":"SCRIPT_OF_API_VERSION_2X_MUST_IMPLEMENT_A_SCRIPT_TYPE_INTERFACE",
    "message":"SuiteScript 2.1 entry point scripts must implement one script type function.",
    "id":"",
    "stack":["Error\n at Object.beforeLoad (/SuiteScripts/XXX/your_usereventscript_file.js:YY:ZZ)"],
    "cause":
    {
        "type":"internal error",
        "code":"SCRIPT_OF_API_VERSION_2X_MUST_IMPLEMENT_A_SCRIPT_TYPE_INTERFACE",
        "details":"SuiteScript 2.1 entry point scripts must implement one script type function.",
        "userEvent":null,
        "stackTrace":["Error\n at Object.beforeLoad (/SuiteScripts/XXX/your_usereventscript_file.js:YY:ZZ)"],
        "notifyOff":false
    },
    "notifyOff":false,
    "userFacing":true
}

There are several things you can check to find out what’s causing the real problem:

  1. If you’re pointing to a Client Script, where the User Event Script is loading up a button on the form check that the header area of your Client Script doesn’t specify @NApiVersion 2.1 (note the .1), it needs to read @NApiVersion 2.x (or @NApiVersion 2.0).
1
2
3
4
5
6
/**
 * @NApiVersion 2.x
 * @NScriptType ClientScript
 */

// etc
  1. Another thing to check if your User Event Script is pointing to a Client Script is to check the path if you’re using the context.form.clientScriptModulePath approach.
1
2
3
// ...
context.form.clientScriptModulePath = "./my_cs_script.js";
// ...

If you’re using the relative path it needs to be relative to the location of the User Event Script file it is being referenced from.

You don’t necessarily need to append the .js extension to the file, but I do it out of a good habit.

  1. Don’t forget the other obvious check if you’re using TypeScript and compiling that to Javascript: ensure you’re using export on your beforeSubmit, afterSubmit and/or beforeLoad functions in your Typescript code.