Coldstar
Coldstar

Reputation: 1341

Including custom modules in SuiteScript 2.0

I am trying to reference a custom user module in a SS2.0 index script like so:

/** * @NApiVersion 2.x * @NScriptType Restlet */ define([ 'N/record', 'N/error', "SuiteScripts/MyFolder/src/My_Controller", 'N/crypto',

Which works fine in sandbox. However when we deploy to production (bundle push) we get the following error when we call a RESTlet method:

You do not have permission to load this module SuiteScripts/MyFolder/src/My_Controller.js, it has an @NModuleScope of SameAccount which restricts its availability to customization objects created in account 1234566

All we did was:

  1. create a RESTlet using our index file (SS2.0 does not allow you to define libraries)
  2. deploy/bundle RESTlet
  3. Upload the custom user modules (My_Controller.js) manually to the cabinet with Eclipse to the production account (CTRL+U)
  4. Call a method on RESTlet (in production) using Postman

Can anyone see what we are doing wrong? Thank you

Upvotes: 2

Views: 5095

Answers (1)

Eidolon108
Eidolon108

Reputation: 403

You are correct, you are missing "@NModuleSc​o​p​e Public". See https://netsuite.custhelp.com/app/answers/detail/a_id/49326

You can set the argument to any of Public, TargetAccount or SameAccount. This allows you some control over what other scripts can load your module. If you do public, any bundle can run the script. If you want to avoid this, you can leave it to SameAccount and make sure your My_controller.js is in the same bundle as the restlet.

Upvotes: 3

Related Questions