I'm very much a newbie to SuiteScript and not much more than that to Javascript.
I have a single file which contains all my functions and so forth which I upload to NetSuite and deploy - all good. But I want to create and use a Class, creating instances of it from the file I upload.
So how do I do it? Does the Class declaration need to be in another Javascript file? Can I do it all in one file? If I can do it all in one file, what's the syntax? I can't get it to work in one file; it always throws an error. If I can put it all in another file, what's the syntax in that file? And then how do I include it in the first file?
Here's a shortened version of my Javascript file:
define(['N/search'],
function (search)
{
function fieldChanged(scriptContext)
{
// Code here where I create and run a search. I want to put each result
// from the search into an instance of the class I want to create and
// store all of those instances in an array.
}
return {
fieldChanged: fieldChanged
};
});
The class declaration, I know, looks like this:
class Result
{
constructor(name)
{
this.name = name;
}
}
But where do I put that declaration?
Sorry if this is a really dumb question.