I'm putting together a custom module for creating ...
# suitescript
k
I'm putting together a custom module for creating scripted versions of custom/native fields that need to be filtered but cannot be through the UI. Some of my code is client side and some is server side. Is it possible to put both client and user event code in the same module file?
s
I may misunderstand the ask, but can you not put the common code into a module that is imported by each client/UE script?
k
That was the plan, but the client code uses
N/currentRecord
so the user event throws an error as soon as the page loads
is there maybe a way to do a conditional import?
otherwise I guess I can just do two modules, one client and one user event
I separated them into a UE module and a Client module and it works without errors now.
s
that sounds like it makes sense to me (assuming you still were able to factor out common logic to its own module)
basically, assuming the inside logic is the same, abstract away the N/currentRecord vs N/record choice
k
The client code is only run in client scripts and the user event code is only run in user event scripts. They have no shared code between them, so it makes sense to me to have them in separate files
👍 1