Posts Tagged Netsuite
SuiteCloud Developer AccountYou don’t want to touch the data/configurations of the production account of your client and you don’t have access to the Sanbox account. Or, you want to develop a SuiteApp as a product rather than for a particular client. NetSuite offers a Community SuiteCloud Developer Network account for free .
Search BoxAre you a shortcut addict? Feel uneasy to move the mouse to much and always find ways to reduce number of clicks and key presses? Then this tip should work great for you.
Script DebuggerIts often painful to make changes to scripts on our machine and then upload them to File Cabinet, before you can see the script running. This becomes even more harsh if the changes is as short as one character. In such a scenario, use the Script Debugger. Make changes online and debug it right within your browser. Keep in mind that the process would require some patience because of back and forth calls between NetSuite and the web browser.
SuiteScript APICode Auto-Completion is a great feature. However, there is little help offered by IDE’s in case of loosely typed languages like JS. If you like to get some help with auto-complete, download SuiteScript API from NetSuite File Cabinet. This is a JS file you should add to your project with other SuiteScripts.
Domain KnowledgeIf you only have a background in software development and have no prior experience of working with ERPs/CRMs, you might find it handy to go through the basics of NetSuite ERP/CRM domain. Try out Netsuite for Dummies.
So the idea is to write client and server-side code alike and use the toString() method of the client-side functions to aggregate the client-side script.
Lets take a simple scenario. We are creating a user registration form within a Suitelet using plain old HTML form elements.
- When the user inputs first and last name fields we would like to suggest a user name.
- When the user inputs a password, we would like to warn if it contains the first or last name.
Here goes the script:
The highlighted lines contain the script that is problematic. Its difficult to read, refactor and debug.
Here is the improved version of the code:
Notice the changes from the previous version:
- All the client-side functions now coexist with the server-side code
- The getClientSideCode() function has the references of all client side functions. It iterates over all of these to append each to the client-side script.
Pros and Cons
The latter code is much better than the earlier version.
- The client-side code is easier to maintain. Its free of noisy code/characters like extra semicolons, quotes and annoying escape sequences.
- One can use the features provided by the IDE to make change in the code such as renaming identifiers and code formatting.
However there are a few limitations to this approach that must be taken care of .
- The IDE has no means to discriminate between server and client-side functions so the developer has to be careful using intellisense/autocompletion to avoid calling client code in server-side and viceversa.
- Every time you create/remove a client-side function you need to update the collection of functions(arrFunctions in the code example).