Our team is looking into simplifying the NS UI pre...
# suitescript
c
Our team is looking into simplifying the NS UI presented to our CSRs. While looking at SuiteAnswers, it seems the following are our best options: - Suitelete     - Probably a set of Front and Backend Suitelets     - The idea would be to have a single interface to:         - mangage the Sales Order & Cash Sale two step that is needed to charge an SO         - view and modify Customer data         - manage auxilary records related to Customer data - REST-let     - This would be used to gather information from NS to present to customers on our web store     - things like:         - scheduled shipment             - next shipment             - previous shipments             - order status         - order history         - order status I've not written anything quite so ambitous before. Would this be a resonable method for going? Should I be putting this stuff into a SDF thing?
s
create a SPA that uses NS as a generic data backend.
c
That is also a possibility. 🤔 Would I need a RESTlet or something like it for NS to act as a generic backend?
s
Yes, you can use a restlet or a Suitelet as the backend.... or if you're brave you perhaps could try the new beta JSON api. Though using both a suitelets and restlets is something I know works well.
c
Good to know. Thanks @stalbert.
@stalbert Would you mind answering a couple more questions about building a SPA wrapper for NS?
s
what's on your mind?
c
While digging though the SuiteAnswers docs I saw there is a whole section of UI tools/functions(? -- I'm still new to development) that seem like they would be good to use for a Suitelete. So I guess the questions are: • what's it like to write a SPA wrapper for NS? • Is that better than trying to leverage their SuiteScript tooling? (I've picked up a few terms of art. 😉) I've seen some of the complaints about SDF and "native" SuiteScript and well we don't have the budget to burn too much time, so I'd like to try to limit the amount of waste.
s
One benefit of doing a SPA is you can leverage all the know-how, documentation and tooling available for whatever web framework you choose (or no framework if you prefer). If you're new I'd recommend using VueJS as it's easy to get started and is well documented. then all you need to do is simple JSON input/output via restlet or suitelet.
You also get the creative freedom to make your mini app look and feel however you like - you're not stuck in the box UI Suitelets provide.
c
I appreciate the insights @stalbert. I've been going back and forth between Vue & Ember. I like that Vue is well documented, I also like the Ember is STABLE, so if I were pass this project on to another dev, they may not "like" my choice but at least it's not going to break on them.
To structure this sort of thing, you make a Suite/REST-let that gives access? This is something that I am not getting a very clear view of from the SuiteAnswer docs. 😕
s
I wouldn't rely on SuiteAnswers much for this. If you host the SPA in the netsuite file cabinet, then you'll have an existing login session for authentication. You then make calls to a data-only Suitelet or a restlet.
c
<-- making notes Ok, these terms are something I can do more searching on. Thanks for your help!
If I'm hosting the SPA via NS files, how do I give my users access? Is that just a simple setting or do I need to look for some specific URL? After this I'll let you alone, while I do more research, promise. 😉
s
You provide a link to the file cabinet that represents your compiled app main file. Put your app in the Live Hosting Folder then bring up your home page (usually index.html or something) in NS and use the links shown there, only change the domain to match the domain your users use to login (to carry the login session over to your app).
The elegance of this approach is it gives you full flexibility (you can design whatever you want, really) while having NetSuite host the solution and handle login/user session.
c
Thank you so much for this! I appreciate the "high level" view, so I can frame up my searching in the help docs and app framework docs.
One more dumb question. When writing the SPA, I'd just use SuiteScript to access the NS functionality correct? I'm reasonably sure that's correct but just checking for a little confirmation.
s
you just create RESTlets and/or Suitelets that accept JSON, do some (usually CRUD like) operation in SuiteScript, then return a JSON result
we actually created a framework for creating APIs like this, to provide common structure to request/responses, consolidated error handling, etc. so that the 'commands' invoked by the SPA app would just be a single function in SuiteScript
I'd recommend you create something similar to make life easy both for your SPA app and your SuiteScript implementation of business operations.
by the way, none of these are dumb questions.
🤩 1
c
Ahhh. OK. That makes a whole lot more sense. So there's SuiteScript it's "the source". Then you put a "Universal Translater" over it (aka the RESTlet as API). Then the SPA speaks to the UT in REST/JSON which is then interpreted by SuiteScript as SS commands because of the RESTlet.
I'm sure my coding ignorance is showing. 😱
s
yes, and although a restlet automatically handles JSON for you, it can be helpful to establish a common shape for all requests and responses
✔️ 1
one popular example is to ensure all responses from the api conform to a shape something like
{ errors: [], data: []}
in our case, we use the restlet/suitelet to automatically do things like catch exceptions and serialize them into the
errors:[]
array
also a benefit of a structure like above is it allows a single request to return multiple errors, or a combination of errors and data (i.e. partial success/partial failure conditions)
high five 1
c
I really appreciate the insights!
s
no problem. doing something like strictly adhering to '{errors:[], data..}` may sound like overkill but it is a simple solution to situations you're likely to encounter so thinking up front helps!
💯 1