:point_up: I would love to hear other people's tho...
# suitescript
m
☝️ I would love to hear other people's thoughts on this, as I have seen suggestions floating around a couple of times for using
N/cache
as a way of passing data around and my understanding is that this a potentially risky missuse of the API. Can anyone validate my opinion or tell me I am wrong?
✔️ 1
n
I agree with you. I didn't see the official clarify how
N/cache
desert data so I choose not to use it in this case. normally I use
N/file
to hold the counters/totals.
create a JSON, keep it in a *.json and use
JSON.stringify()
and
JSON.parse()
to write and read. (waiting for a better solution)
e
Would a custom record be faster than a File?
and when you say "pass data around" what do you mean?
r
I believe he meant passing data from each stage of the Map reduce
m
A custom record might be faster than a file, but it will depend how you're using it. A direct record lookup can be faster than looking up a file and parsing it, but having to search for your storage custom record will obliterate any possible gains. I'd just go with the json solution @nzy suggested.
k
I have used N/Cache to pass something from one suitelet to another suitelet as only way i could find to do it. Script parameters on the redirect didnt work for some reason.
Also used to pass value from one step to another in suitelet assistant.
Need to find a better way but working for now.
n
another reason to choose JSON is the flexibility of data structure a JSON can bring to you. Since M/R works parallelly, saving a few ms by using custom record seems less tempting.
m
@erictgrubaugh the conversation yesterday was passing data around M/R stages (which is a different topic because that would probably indicate something wrong in the design..) but I mean generically - I've seen this suggested to pass between entry points on a User Event, or between different script types etc.
💯 1
@karlenigma did you try using the session?
runtime.getCurrentSession().set({ name: "myKey", value: "myValue" });
k
yeah we did try that but to no avail either.
Not sure why neither of them worked tbh.
I’m sure if i shared my scripts there would be holes!!
lol
It’s the files on each step i am having issues with. The dev that built the assistant has got all records that are being created being saved in FINISH.
m
Lol I have painful memories trying to use assistants. I gave up and wrote mine as a SPA in Vue.js (actually starting building a component library that mimics NetSuite UI so it looks almost identical to a Suitelet).
💯 1
k
TBF that was something i wanted to do but seemed prudent to use the NetSuite UI
plus had a small window to get it done.
s
I think one should pass data between MR stages directly (e.g. context.write()) - i.e. not rely on a mechanism outside M/R. I agree with @michoel - if passing the data directly doesn't fit then you may need to change how you're modeling the process. Also note that IMHO map/reduce is NOT a silver bullet. If it's difficult getting a use case to fit the NS M/R model maybe you shouldn't be trying to fit a square peg in a round hole.
I also agree with @michoel about doing a SPA. In my view, SPA should be considered for anything but perhaps the most trivial of UI Suitelets. The documentation and freedom and flexibility in addition to community support with the popular web libs makes this a no brainer. It also means regular web devs can develop it.
m
I know NetSuite says they are working on official SPA support. Unfortunately from what the PM mentioned on chat here once they are not going with a mainstream framework like React/Angular/Vue but rolling out their own version and I really think they missed the boat there. Like you say they could have capitalized on the communities etc behind them.
k
Sorry but SPA?
m
Single Page Application
Basically using ajax to dynamically update the page instead of having to refresh.
k
Ah yeah sounds like an idea
s
Albert mentioned the other day that the SPA support would be framework agnostic?
k
Need it now!! Assistant is rubbish!!
m
@stalbert I must have missed that. Do you have a link to the message? Nothing coming up in search.
s
https://bit.ly/33W6h5F page 15. OpenID may be an exciting new option for some as well?
m
I'm confused, is there something in the release notes about SPAs?
e
About Tokens, I think
m
😕 When were tokens mentioned in this conversation?
k
@Albert Margarit (NS Eng Lead) didn’t you mention something about SPA’s somewhere??
I’ll beta test lol
m
I spoke to @helen about this a couple of years ago, not sure if she is still active on Slack
a
Yes, we are working in native (and true) support for SPA so you can plug whatever you want
k
Any timescale?
a
🤐
work in progress 🙂
s
sorry, I must have mixed up a TBA conversation within this one