<https://jonesdev.github.io/2021/03/26/sending-sys...
# suitescript
r
https://jonesdev.github.io/2021/03/26/sending-system-alert-messages.html Disclaimer: I'm not 100% sure on the rules of 'self-promotion' - please feel free to delete this message if it's against the rules. I've started to write about my experiences while developing within NetSuite in order to try and share some knowledge with the wider community and also receive feedback in return. Be interested to hear what people think
❤️ 1
👍 1
b
Only partially constructive, but i find it hilarious that the error logging code logs errors using the same method it tries to replace
r
@battk - Yeah, I see your point. It's just a 'fail safe' really, it's not ideal I agree.
Well, not even a fail safe.
b
onto the suitescript related advice, use search.lookupFields
its also likely that your webhooks url will not change often, which makes this a candidate for N/cache, in which case you would probably do a more normal search
2 usability notes
you probably want to have functionality to nicely add an error to your body
and you probably want to change what you return
its unlikely you want people to write code for when the response code is not in the 200 range
r
lookupFields sounds good - I'm guessing you're advising this since it uses 1 governance unit (iirc) rather than the 2 to load a record? On the caching topic - how does that work as it's not a deployed script of any sort? I just import it when needed in my other scripts. I haven't done much work with the N/cache module before so I'm glad you're pointing this out. Not sure what you mean by 'nicely' adding errors to the body since you already control what message is being sent from wherever you decide to call this function - we've found it currently works in a good way for us. I sort of agree on the return point, at the time I wasn't really sure what to return and it was more of a PoC piece of work but we've not had to use the return response before anyway - this was by no means an attempt to officially 'release' a script/package but just to share a concept. I appreciate you taking the time to outline your points, very useful - what did you think of the concept/idea in general?
b
for caching, you can make a public cache available to all scripts
you can avoid loading or searching your custom record after you have done it once
my comment about error is that you want to make it easier to log the error, doing thing like making sure all the important properties of the error are in your message
automatically adding an error to your message in a consistent way will probably cut down on people not logging errors correctly
especially if they do things like only log the name or message and skip the stack
as for the concept, netsuite handles errors as emails
id probably check into sending an email to a channel
d
rollbar is good for logging errors, I use that a lot and it has a decent free plan