<@U013PDCADJ5> What does your define declaration l...
# suitescript
s
@Sim Greenbaum What does your define declaration look like?
s
/**  * @NApiVersion 2.1  * @NScriptType UserEventScript  * @NModuleScope SameAccount  */ define(['N/record', 'N/search', 'N/https', 'N/runtime', 'N/file','N/xml','N/error'],     /**      * @param {record} record      */     function (record,https) {         function beforeSubmit(scriptContext) {
s
So, you are trying to import seven modules, but only assigning them to two variables. In this case, N/record is assigned to record, while N/search is assigned to https. The N/https is not assigned to anything. you have to add the same number of parameters to the function, and in the same order, as the array in the define declaration.
☝️ 3
s
this is where TypeScript shines - using
import
syntax you can't possibly get this wrong
s
I'm still getting the same error
Copy code
/**
 * @NApiVersion 2.1
 * @NScriptType UserEventScript
 * @NModuleScope SameAccount
 */
define(['N/record','N/https'],
    /**
     * @param {record} record
      */
    function (record,https) {
        function beforeSubmit(scriptContext,https) {
s
beforeSubmit
only takes context, nothing else. Are you using some sort of templates, hopefully? https://stoic.software/effective-suitescript/script-templates-for-suitescript-2-0/
❤️ 1
s
thanks i relized that right after wards
r
+1 for TypeScript as mentioned by @stalbert Much more cleaner too IMO.
s
syntax I use is
import * as record from "N/record"
(i.e. using native ES modules syntax, not assuming 'require' exists, the compilation to UMD target takes care of that)