https://netsuiteprofessionals.com logo
#suitescript
Title
# suitescript
j

Josh Godfrey

04/20/2022, 7:58 PM
Playing around and trying to custom Module that will hold functions shared across multiple Client Scripts, but I keep getting an
error.SuiteScriptModuleLoaderError
Full Error:
Copy code
Fail to evaluate script: {"type":"error.SuiteScriptModuleLoaderError","name":"UNEXPECTED_ERROR","message":"missing ; before statement (/SuiteScripts/Employee Equity/plx_cm_employee_equity_module.js#8)","stack":[]}
Client Script Sample:
Copy code
define(['N/error', 'N/query', 'SuiteScripts/Employee Equity/plx_cm_employee_equity_module'],
    
    function (error, query, plx_cm_employee_equity_module) {

        
        function pageInit(scriptContext) {
            log.debug('pageInit fired')
        }
Custom Module Sample:
Copy code
define([],
    function () {
        let counter = 0

        const incrementValue = () => {
            counter++
        }

        const getValue = () => {
            return counter
        }

        return {
            incrementValue : incrementValue,
            getValue : getValue
        };
    });
also tried
Copy code
define(['N/error', 'N/query', './plx_cm_employee_equity_module'],
m

mattdahse

04/20/2022, 8:13 PM
Client scripts don’t support 2.1 syntax yet. Your module uses arrow notation instead of an explicit function declaration.
j

Josh Godfrey

04/20/2022, 8:14 PM
ahh, thank you
Yep, that worked. Thank you @mattdahse
m

michoel

04/20/2022, 10:15 PM
You can have 2.1 client scripts as of 2021.2 IIRC