I understand that i can use N/ui/message module to...
# suitescript
d
I understand that i can use N/ui/message module to display the message like in this Blue square below using client script, but i want to show the message when user
view
Purchase Order, as what i understand
pageInit
will not run on View mode. Please suggest any way to achieve this ? Thanks
d
wow thanks @michoel i will try it
s
A user event
beforeLoad
script will definitely work. We have two UE scripts that do this, to add alerts in View mode.
s
@scottvonduhn, I'm curious if there's a particular reason you define that with
const beforeLoad = (context) => {
rather than just
function beforeLoad (context) {
?
also @dennysutanto nice drawing of a cat up above.
d
haha i didn't realize it looks like a cat until you said so @stalbert
@stalbert, I believe @scottvonduhn is using suitescript 2.1, as what i understand the () => {} syntax is an ES6 syntax
👍 1
s
It's just our company's JS style guide/preference. You could make it SS 2.0 syntax easily, it will behave the same.
s
I was curious because
function foo()
is also ES6 syntax 🙂 and since arrow functions assigned to a variable are not the same as a function statement I thought maybe there was a particular technical reason to choose that over
function foo()
. There are subtle differences between a const variable assigned a function expression with an arrow function and an old school function statement.
s
No real preference on my part. Sometimes the arrow syntax can be shorter when there is an implicit return, and no braces, but for this instance, it's actually longer. I find both about equal in terms of readability, but that is obviously very subjective and personal.
s
I was thinking about the tangible differences like how
this
is handled, when you can use the function (only after declaration in the case of function expressions) and the potential for missing/different info in stack traces should the function throw an exception?
s
yeah, there are some differences, and I think assigning the function expression to a const or let variable could limit its scope and where it can be called
d
@scottvonduhn @michoel thanks the above works