Hello, how to use N/file in a custom module ? Or h...
# suitescript
c
Hello, how to use N/file in a custom module ? Or how to load a file from File Cabinet > Images in a custom module script ?
r
You can pass NetSuite modules in the define array/function wrapper like you normally would.
file.load()
c
Thank you @reptar. I found the solution: N/file module is not available in custom scripts so I had to create a suitelet to use load my file and then call my suitelet in my custom script with N/https
r
Oh? What do you mean by custom scripts? Is this a portlet script, or... ?
Custom scripts is a term often used to define suitescripts in general
Many of which do have the file module enabled
Custom modules have access to the modules of whatever entry point they are attached to
c
I meant a script file of this type :
In this type of script you can't use file.load() from N/file module
r
Yes, you can. You have access to whatever N modules of the calling script type. If you attach a custom module to a client script, you can import any of the client "N/" modules into your custom module.
Because custom modules can be used with a variety of script types
It depends on the script the CM is attached to
c
It is attached to a user event script but when I try to use file.load from the N/file module in my custom module I get an unexpected error
But when I call it in a suitelet script it works fine
r
SuiteLet is fine, but it should be possible to do in a CM. I would add the module and debug from there