Browsed by
Tag: clientscript

Suitescript 2.0 Quickstart Examples

Suitescript 2.0 Quickstart Examples

Here I will be posting the most used scripts from Suitescript 2.0. These code examples are meant for beginners to be a quick start so they can quickly get a script started and add their┬ácode to them. I tried to keep them short. If you are a beginner I recommend you to check Netsuite’s Help section and navigate to Suitescript 2.0 API so you can learn more about each.

 


Client Script

Note: Check out how the helper functions in clientscript have to be nested inside the main runClientscript function. This is something particular to client scripts.


User Event Script


Scheduled Script


Suitelet


RESTlet

Leave a comment if you want to see other examples.

SuiteScript 2.0 Dialog Prompt + On SaveRecord

SuiteScript 2.0 Dialog Prompt + On SaveRecord

One of the new modules in Suitescript 2.0 is the “N/ui/dialog” module but unfortunately it doesn’t include a prompt method. I did some digging and found that the dialog module uses┬áSencha Ext JS. Since Ext JS doesn’t require the dialog module it can run on both SS 1.0 and 2.0!

Here’s how they look like side by side:

Native JS

jsprompt

Ext JS

extjsprompt

Note: This is a hack.

Here’s the code sample on how to achieve this (Works on both SS 1.0 and SS 2.0):


Additionally, thanks to this post from Abaci I was able to run this code right before the record is saved, which can be very useful to set the value of a field right before saving.

Here’s the code sample running on SaveRecord in SS 2.0:

I hope that was useful for you. Don’t forget to leave a comment if you have any questions!