Hi all! Anyone faced the Unknown Error during N/cu...
# suitescript
d
Hi all! Anyone faced the Unknown Error during N/currentRecord import in 2.1?
When I change script type to 2.0 it's working as expected.
b
what does the code look like
d
basically just
Copy code
import currentRecord = require('N/currentRecord');
b
no import statements
unless you are using a transcompiler to remove the import
d
Yes, sorry. I do use transcompiler. Let me try to build a sample script.
Copy code
/**
 * @NApiVersion 2.1
 * @NScriptType ClientScript
 * @NModuleScope SameAccount
 */
(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "N/currentRecord"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.addContact = void 0;
    const currentRecord = require("N/currentRecord");
    function addContact() {
        console.log(JSON.stringify(currentRecord));
    }
    exports.addContact = addContact;
});
Here's the minimum transpiled file
Returns Fail to evaluate script: {"type":"error.SuiteScriptModuleLoaderError","name":"UNEXPECTED_ERROR","message":"","stack":[]}
b
meh, you take your chances on that code
it requires N/currentRecord twice
d
Ok, I changed compiler option module to 'AMD' and it returned a cleaner code.
Copy code
/**
 * @NApiVersion 2.1
 * @NScriptType ClientScript
 * @NModuleScope SameAccount
 */
define(["require", "exports", "N/currentRecord"], function (require, exports, currentRecord) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.pageInit = exports.addContact = void 0;
    function addContact() {
        console.log(JSON.stringify(currentRecord));
    }
    exports.addContact = addContact;
    function pageInit(context) {
        if (context) { }
    }
    exports.pageInit = pageInit;
});
So this one fails
Copy code
/**
 * @NApiVersion 2.0
 * @NScriptType ClientScript
 * @NModuleScope SameAccount
 */
define(["require", "exports", "N/currentRecord"], function (require, exports, currentRecord) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.pageInit = exports.addContact = void 0;
    function addContact() {
        console.log(JSON.stringify(currentRecord));
    }
    exports.addContact = addContact;
    function pageInit(context) {
        if (context) { }
    }
    exports.pageInit = pageInit;
});
This one saved successfully (only changed from 2.1 to 2.0)
b
you may want to go to netsuite support
although if you do, i probably would start with a simpler script that you create by hand
d
Yep, a good idea! Thank you!