How to debug / set breakpoints / view logs in map reduce scripts

I’m new to SuiteScript / SuiteCloud development. I come from a Java / Nodejs API development background. And I’m used to debugging, and using breakpoints, and logging within my IDE (Visual Studio Code / InteliJ)

I was wondering where can I learn how Netsuite developers debug Suitescripts? I don’t know how to debug map/reduce scripts or check log statements.

And I’ve seen the Suitescript Debugger tool. But it doesn’t seem to support map reduce scripts yet, according to Oracle documentation.

I’m working on replicating a map/reduce script that makes an API call to retrieve JSON data, and then it should map some of the fields from the API response to columns in a table inside Netsuite — which I believe is a custom record? I can query that Netsuite table using a Database tool.

This map reduce script also grabs an auth token and various client id / secrets / credentials from another custom record too within Netsuite. I’m trying to set break points on that call to grab these API auth stuff too.

 

I’ve seen some developers copy and paste code inside the Google Chrome Inspect tool, to execute some code. It seems like Netsuite development is different from doing development within an IDE.

Maybe this is related to understanding the difference between server side and client side development / scripting?

I’m not really sure what’s the difference between server and client side scripts, and java/nodejs code files. It’s all just code to me. I’d appreciate if anyone can help me understand developing Suitescripts better.  Thanks.

Rookie Asked on August 16, 2023 in SuiteCloud.
Add Comment
1 Answer(s)

It is not possible to debug a Map/Reduce script in real time.

I think your understanding is pretty much there. The Google Chrome Console is good for testing client side functionality, the Suitescript Debugger is good for server side functionality. However, in all honesty, I only really use either of them for running test snippets of code.

Script logging, for me, represents the most useful debugging tool but clearly lacks some of the inspection / navigation options you may be used to from elsewhere.

Back to Map/Reduce scripts…

When you set up the Map/Reduce script you will have a script deployment record and under there you will find the Execution Log. Within the script itself, you may add log.debug() (assuming SuiteScript 2) statements and the output will appear in the Execution Log.

The only other work of caution with respect to Map/Reduce scripts is that, due to the distributed nature of the process, some errors will not necessarily be reported immediately. The summarize() function allows you to log these and so it’s quite important to get something in there from the start to make sure you aren’t faced with a blank log. I usually log the start of the script too in getInputData() and the end at the bottom of summarize().

There’s a boilerplate summarize() function here, since the included template from NetSuite doesn’t appear to contain anything:

https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_4413276323.html#bridgehead_4472688344

I hope that help and let me know if you have any further questions.

Intermediate Answered on August 19, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Become a Sponsor   Become a Sponsor