Activate SuiteCommerce Advanced Extension

When I tried to add a SuiteScript file in the SuiteScript2 folder, I am getting this error while activating the extension.

{“type”:”error.SuiteScriptError”,”name”:”14978″,”message”:”Invalid define call, define should only be called once per module. Define calls found at the following line numbers: tmp_ssp_libraries_ext.js 34, 69, 108, 136, 167, 205, 231, 262″,”stack”:[“createError(N/error)”],”cause”:{“message”:”Invalid define call, define should only be called once per module. Define calls found at the following line numbers: tmp_ssp_libraries_ext.js 34, 69, 108, 136, 167, 205, 231, 262″,”stack”:[“createError(N/error)”,”reduce(/SuiteBundles/Bundle 455185/ExtensionMechanism.Server/CompilersMapReduce/SspLibrariesCompilerMapReduce.js:295)”],”name”:”14978″},”id”:””,”notifyOff”:false,”userFacing”:true}

 

Here is my code:

/**
* @NApiVersion 2.x
* @NModuleScope Public
*/
define(“Adeel.Customization.customization.ServiceController”, [‘N/record’, “ServiceController”], function(
  record,
  ServiceController
) {
  “use strict”;
  return ServiceController.extend({
    name: “Adeel.Customization.customization.ServiceController”,
    // The values in this object are the validation needed for the current service.
    options: {
      common: {}
    },
    get: function get() {
      return JSON.stringify({
        message: “Hello World I’m an Extension using a Service!”
      });
    },
    post: function post() {
      // not implemented
    },
    put: function put() {
      // not implemented
    },
    delete: function() {
      // not implemented
    }
  });
});
Rookie Asked on December 19, 2022 in SuiteCommerce.
Add Comment
1 Answer(s)

I am reasonably sure that you are getting this error because you have attempted to call ‘ServiceController’ in your SS2 extension which is a core SCA module. Extensions SuiteScript 2 cannot call core SCA modules — only generic SuiteScript 2 modules or modules that you have already defined in the extension.

You are completely free to reimplement service controllers in your extension if you really wish, but the recommended approach is to use service files. See my example here: https://github.com/oracle-samples/netsuite-commerce/blob/master/samples/2020-2/Example-part10-final/Modules/UserPreferences/SuiteScript2/Example.UserPreferences.Service.ss

Beginner Answered on November 22, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Become a Sponsor   Become a Sponsor