RE: Calling SS2.0 modules from SS1.0 and passing context object

Not sure if this is possible….I have an overly complex set of Custom Form Scripts written in 1.0 that I don’t have time to replicate in 2.0 right now.  I’d like to be able to call some code that resides in a SS2.0 module.  I can call functions in the module while in SS1.0 by using require(['/SuiteScripts/2.0/module/my_module'], function(my_module) {my_module.myfunction();}); and it’s reaching the function ok.

The problem is, this function expects to be called from a SS2.0 PageInit, and be passed the context object that’s available in SS2.0 Custom Form (Client) Scripts.

Is there a way to access or create this context object inside my SS1.0 script?  More simply, is there a way to gain access to the context object somehow OTHER than when it’s passed in by default to PageInit() and other functions in a SS2.0 Custom Form (Client) Script?

jen Beginner Asked on May 13, 2020 in SuiteScript.
Add Comment
2 Answers
(function (global) {
 global.myNamespace = {
  pageInit: function (type) {
   require(["/SuiteScripts/2.0/module/my_module", "N/currentRecord"], function (
   ) {
    currentRecord.get.promise().then(function (theCurrentRecord) {
     my_module.myfunction({ currentRecord: theCurrentRecord, mode: type });

Create your own context object and use N/currrentRecord to get your currentRecord. Keep in mind that require is asynchronous.

Advanced Answered on May 14, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.