Hi, I'm trying to fetch some data in beforeLoad th...
# suitescript
w
Hi, I'm trying to fetch some data in beforeLoad that is needed in the client script on an order form. Is is possible to set is as a session object in BeforeLoad that is also passed to the client? I'm trying to do that but can't get the objects in the chrome console. I've tried these in the beforeLoad:
Copy code
context.setSetting('SESSION', 'beforeLoadpSetupArr', JSON.stringify(pSetupArr));
context.setSessionObject('beforeLoadpSetupArr2',JSON.stringify(pSetupArr));
context.setSetting('SESSION', 'beforeLoadpSetupArr3', pSetupArr);
context.setSessionObject('beforeLoadpSetupArr4', pSetupArr);
And then just trying to get them in the console with:
Copy code
window.sessionStorage.getItem('beforeLoadpSetupArr');
Or maybe I just should set the values on a custpage-field?
b
session objects are server side only
w
Ok, this SA led me to believe that is was possible to store objects there from the serverscript: https://netsuite.custhelp.com/app/answers/detail/a_id/38203/kw/client%20session%20object Thank you for verifying my suspicion that it won't work. I have already implemented storing the variables in custpage-fields. Do you have a better way of doing it? what I'm doing is running a two searches in beforeLoad instead of pageInit, which is much faster. And would like to pass the result to the client script.
b
that article is specifically only for client script
im not really sure why a search in server script is much faster than client script
w
It's because I'm elmininating all the logic between the client and the server I suppose
b
whats the difference in speed?
w
the search in pageInit takes 500ms-1000ms (depending on server-load) and the same search in beforeLoad takes 25-100ms
even down to 5ms for one of the searches. It fluctuates a lot.
b
you can try looking at your network tab in your browser's console to see the timings
w
yeah, I'm running the profiler in Chrome. So there's two searches. the first takes around 400ms in client and on average 70ms on server the second takes around 250ms in client and 10ms on server.
message has been deleted
The nlapiLookupFields have been moved to the beforeLoad as well, they went down from around 100ms each to 3ms.
b
interesting, while i think client script is terrible in general, i never thought to move stuff from it to server script would be that much faster
w
When you have this much server time just to load a record in edit-mode, you want to optimize as much as possible.
😣
b
I know this can vary wildly, but your server is pitifully slow for what should be offpeak hours
👍 1
w
Thank you!
If I may ask, how many lines did you have on that order, and how many custom columns do you have?
b
extremely few. its from a test account
w
ok, good to know. This has ~200. But comparing to an account with ~40, I get a similar figure like yours.
b
anything above 100 is not meant to be touched in the ui
honestly above 20 is miserable
w
Oh, I was talking about custom columns, not lines.
Lines was 18.
Here's the correlation with the number of lines
b
id say your sales order has too much data on it
w
mmm, me too
b
your graph visual annoys me with those missing datapoints
w
haha
I fully understand. 😄
I could only refresh one page at a time for the performance logging to occur and I took 5 datapoints for each number of lines. sooo, 75 agonizing refreshes. 😒
b
you may be interested in the apm bundle for performance logging
w
Yeah, that is were I'm getting the data. But it seems there is some bug where it doesn't log any performance data unless I load one tab at a time.
b
not terribly surprising, performance data is stored in cookies