So it's late on Friday and I'm still trying to get...
# suitescript
c
So it's late on Friday and I'm still trying to get a
pageInit
function to fire on a client script. I can see the function in the debugger tools and put a break point on it but it never fires. I have a nearly identical function in another script that works great. I can't understand what might be going on...
b
what does the script deployment and script record look like
c
I didn't deploy it. I used it the same way I used a client script on a suitelet, just declared it in clientScriptModulePath attached to a user event script.
I'm wondering if I need to create another script just as the client script?
b
should function the same, what does the script file look like
c
that pasted rather ugly
b
ill take the compiled version
c
Copy code
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
*/
var __importStar = (this && this.__importStar) || function (mod) {
  if (mod && mod.__esModule) return mod;
  var result = {};
  if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  result["default"] = mod;
  return result;
};
define(["require", "exports", "N/currentRecord", "N/https", "N/runtime", "N/log", "N/url", "N/error", "N/ui/message"], function (require, exports, currentRec, https, runtime, log, url, error, message) {
  Object.defineProperty(exports, "__esModule", { value: true });
  currentRec = __importStar(currentRec);
  https = __importStar(https);
  runtime = __importStar(runtime);
  log = __importStar(log);
  url = __importStar(url);
  error = __importStar(error);
  message = __importStar(message);
  var RESTLET_SCRIPTID = 'customscript_ds_restlet';
  var RESTLET_DEPLOYMENTID = 'customdeploy_ds_restlet';
  var SUITELET_SCRIPTID = 'customscript_ds_config_sl';
  var SUITELET_DEPLOYMENTID = 'customdeploy_ds_config_sl';
  var API_SUITELET_SCRIPTID = 'customscript_ds_api_sl';
  var API_SUITELET_DEPLOYMENTID = 'customdeploy_ds_api_sl';
  var endpoint;
  (function (endpoint) {
    endpoint[endpoint["restlet"] = 0] = "restlet";
    endpoint[endpoint["suitelet"] = 1] = "suitelet";
    endpoint[endpoint["api_suitelet"] = 2] = "api_suitelet";
    endpoint[endpoint["landingpage"] = 3] = "landingpage";
  })(endpoint || (endpoint = {}));
  exports.pageInit = function (context) {
    // this is a necessary placeholder. This will compile without this 
    // function but NetSuite will not allow the file to be uploaded to 
    // the file cabinet without at least one formal script entry point.
    var otcError = context.currentRecord.getValue('custpage_onetimeconfig_error');
    var acctChangeError = context.currentRecord.getValue('custpage_accountchanged_error');
    if (otcError) {
      var myMsg = message.create({
        title: 'Configuration Needed',
        message: otcError.toString(),
        type: message.Type.WARNING
      });
      // show the message for 15 seconds
      myMsg.show({ duration: 15000 });
    }
    if (acctChangeError) {
      var myMsg = message.create({
        title: 'Account Has Changed',
        message: acctChangeError.toString(),
        type: message.Type.WARNING
      });
      // show the message for 30 seconds
      myMsg.show({ duration: 30000 });
    }
  };
}
b
did you miss a parenthesis at the end?
c
No, I missed on copy/paste
It compiles and lints fine...
The breakpoint never gets hit.
b
anything weird like multiple scripts trying to set a client script
or even a client script deploymed on the form or record
c
will have to dig for that
good ideas
thx
b
that said, i dont think you can use user event script client scripts for that
those are supposed to be used for buttons
c
I'll fire up another script and see if that does it.
e
Are you expecting this to fire in View mode? No Client Script events fire in View mode, including
pageInit
👍🏻 1