SlideShare a Scribd company logo
1 of 28
Download to read offline
SuiteScript 2.0 API
Netsuite
Released 2015 ∼
July 13, 2018
Agenda
NetSuite at a glance
What is SuiteScript API?
Key concepts of SuiteScript 2.0 API
SuiteScript 2.0 Syntax
HelloWorld Script
Advantages of SuiteScript 2.0
Drawback
Coexistence rules
1
Objectives of this presentation
Understanding the basics of SuiteScript 2.0 API
Explore the key differences between SuiteScript 1.0 & SuiteScript 2.0
2
NetSuite at a glance
Cloud-based business management software
Software as a Service (SaaS)
3
Is a JavaScript API that offers a broad range of options
for enhancing and extending NetSuite
SuiteScript API
What is SuiteScript API?
😟 😎 4
Key Concepts
of
SuiteScript 2.0
5
SuiteScript 2.0 is modular
All SuiteScript 2.0 APIs are organized into modules
Each module reflects the functionality
Concept #1:
6
NetSuite modules & objects
record searchlog file
NS
N
create({}) save({})load({})
∼32 modules
e.g: N/file
∼… APIs
e.g: record.create({});
setValue({}) …({})
Concept #1 (cont’d)
7
Module must be explicitly loaded by a script before using that module’s API
Suitescript 1.0 API
Organized in a Single global library JavaScript file.
Each file gets loaded to every single script regardless of how much API the script use.
Suitescript 2.0 API
Organized and grouped into the modules
Modules are loaded only when they are needed. — based on Asynchronous
Module Definition(AMD)
Now
Before
Modular
Concept #1 (cont’d)
8
Object as Arguments
The arguments passed to methods are typically {key:value} objects
var myObject = {
fieldId: 'greetingMsg',
value: 'Hello, World!'
};
myRecord.setValue(myObject);
myRecord.setValue({
fieldId: 'greetingMsg',
value: ‘Hello, World!'
});
Concept #2:
9
Suitescript 1.0 API
Argument list
Suitescript 2.0 API
Object as argument
Now
Before
‣ Objects
var myObject = {
fieldId: 'greetingMsg',
value: 'Hello, World!'
};
myRecord.setValue(myObject);
nlapiSetFieldValue('greetingMsg', 'Hello, World!');
Concept #2 (cont’d)
10
Script types and their Entry pointsConcept #3:
Script type:
SuiteScript 2.0 scripts consist of several script types
Each script type is designed for a specific type of situation and specific
types of triggering events
Entry point:
Represents the juncture at which the system grants control of the NetSuite application to
the script.
Each script type includes one or more entry points that are exclusive to that type
11
UserEventScript
ClientScript
ScheduledScript
…
Server
(execute on the server)
Client
(execute in the user’s
browser)
Script types Entry points
✦ beforeLoad
✦ beforeSubmit
✦ afterSubmit
✦ execute
✦ fieldChange
✦ pageInit
✦ Etc…
Concept #3 (cont’d)
12
…
Suitescript 1.0 API
Scripts are not Expressive: - hard to recognize the purpose of a script
Scripts are Dependent: - Actions depend on settings done on NetSuite side
Suitescript 2.0 API
Expressive scripts - automatically detected by NetSuite
Independent scripts - No other enhancements needed.
Now
Before
‣ JSDocs tags
‣ Script types & Entry points
function myFunction(){
// logic here
}
sample_script.js
/**
* @NScriptType <script_type_name>
*/
define([], function() {
function myFunction(){
// logic here
}
return {

<entry_point_name> : <entry_point_function>

};
});
sample_script.js
Concept #3 (cont’d)
13
Entry point scripts & Custom module scriptsKey concept #4:
Entry point script:
The primary script attached on the script record
It identifies the script type, entry points, and entry point functions
Each entry point script must include at least one entry point and entry point function
Custom module script:
Is a user-defined script that holds the logic that can be used by other scripts
It’s loaded by an Entry point script as a dependency
Script type(s) declaration is not required
14
Suitescript 1.0 API
Suitescript 2.0 APINow
Before
NS
Script record A Script record B
script_A.js script_B.jsscript_A.js script_B.js
NS
Script record A Script record B
script_A.js script_B.js
‣ Custom module scripts
Concept #4 (cont’d)
15
Same modules used by-
many script records
Anatomy of an Entry Point Script
/**
* @NApiVersion 2.0
* @NScriptType UserEventScript
*/
define(['N/record', 'N/ui/dialog'],
function(record, dialog) {
function doBeforeLoad() {
/* logic of function*/
}
function doBeforeSubmit() {
/* logic of function*/
}
function doAfterSubmit() {
/* logic of function*/
}
return {
beforeLoad : doBeforeLoad,
beforeSubmit: doBeforeSubmit,
afterSubmit : doAfterSubmit,
};
}
);
JSDoc tags:
Required for an entry point script
Entry points:
At least one STANDARD entry point is required for
a script type
Define’s first argument:
List of Dependencies and/or Modules
3
2
1
4
Define’s second argument:
Callback function
1.
2.
3.
4.
Concept #4 (cont’d)
16
Anatomy of a Custom Module Script
JSDoc tags:
NOT Required for a custom module script, but USEFUL.
Entry point:
At least one USER-DEFINED entry point is required for a
custom module
Define’s first argument:
List of Dependencies and/or Modules required by the script
/**
* fileName.js
* @NApiVersion 2.x
* @ModuleScope Public
*/
define(['N/record', ’N/search'],
function(record, search) {
function dummySearch() {
/* logic of function*/
}
return {
myDummySearch : dummySearch,
};
}
);
3
2
1
4
Define’s second argument:
Callback function
1.
2.
3.
4.
Concept #4 (cont’d)
17
Syntax
18
SuiteScript 2.0 Syntax
SuiteScript 2.0 syntax == JavaScript Syntax
๏ SuiteScript 2.0 methods takes plain JavaScript key/value object as an input.
๏ All boolean values take true or false (not T or F respectively)
๏ Parameter types in SuiteScript 2.0 must match as those listed in the Docs/NetSuite help
๏ Enumeration encapsulated common constants (e.g; standard record types)
๏ Sublists and column indexing begins at 0 (not 1)
… except some rules:
19
Let’s create a simple entry point script:
✓ Shows a message on page load
/**
* @NApiVersion 2.0
* @NScriptType ClientScript
*
*/
define([ 'N/ui/message' ], function(message) {
function showMessage() {
var msgObj = message.create({
title : 'Greeting',
message : 'Hello, welcome!',
type : message.Type.INFORMATION,
});
msgObj.show();
}
return {
pageInit : showMessage,
};
});
• Q: Why a Script Type is ClientScript ?
• Q: What is the name of an entry point
in this script ?
A: “shows a message on page”
(does something on a page)
A: “pageInit”
• Q: What is the name of an entry point
function in this script ?
A: “showMessage”
20
Advantages
and
Drawback
21
Some Advantages of SuiteScript 2.0
Enables us to create our own custom modules
✓ Keeps code DRY (Don’t Repeat Yourself): - One module used by many scripts!!
✓ Abstraction : - Later changes don’t affect the deployed script(s)
✓ Possible to add those modules to SuiteApps and expose them to third parties.
Modern programming syntax and behavior
✓ Modeled to behave and look like modern JavaScript — e.g: No nlapi/nlobj prefix
✓ Third party JavaScript API support
✓ Updated sublist and column indexing — (begins at 0 instead of 1)
Functionality enhancements
✓ MapReduce script type : designed to handle large amounts of data.
‣ automatic yielding without disruption to the script
Automatic Dependency management: No need to remember to order of library files
22
Other Advantages of SuiteScript 2.0
Easier to catch-up for non-NetSuite programmers
Easier to upgrade for future versions: easy as changing the
version number
Good and solid documentation with adequate examples
SuiteScript 2.0 the way forward
23
Optional parameters
[e.g; setAge(age = 18)]
Drawback
JavaScript SuiteScript 2.0
Arrow functions
[e.g; (a, b) => a + b;]
Rest parameters
[e.g; avgAge(…age)]
Block-scoped variables
[ e.g; let age = 18; ]
Mismatching of Scripting-language specification:
- JavaScript’s new version is ECMAScript 8 (partially supported), but SuiteScript 2.0 currently
supports ECMAScript 5
There’s a workaround here!, but haven’t tried it yet!! 24
Ex.:
Coexistence rules
1. SuiteScript 1.0 and 2.0 cannot intermix within the same script
‣ You cannot use 2.0 modules as 1.0 Library scripts
‣ You cannot include 1.0 files as 2.0 dependencies
2. The two versions can intermix in the same account, in the same
application, and can even be deployed on the same record.
SuiteScript 1.0 is still supported. however…
25
…however, SuiteScript 1.0 can be deprecated anytime!!!.
Reference
NetSuite Help Center
https://stoic.software/effective-suitescript/2-ss2-
modules/
26
SuiteScript 2.0 API - Documentation
Thank you

More Related Content

What's hot

Firestoreでマスタ取得を
効率化するいくつかの方法
Firestoreでマスタ取得を
効率化するいくつかの方法Firestoreでマスタ取得を
効率化するいくつかの方法
Firestoreでマスタ取得を
効率化するいくつかの方法Hirotaka Nishimiya
 
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdbOwen Hsu
 
Practical experiences and best practices for SSD and IBM i
Practical experiences and best practices for SSD and IBM iPractical experiences and best practices for SSD and IBM i
Practical experiences and best practices for SSD and IBM iCOMMON Europe
 
Redis-SGX: Dmitrii Kuvaiskii
Redis-SGX: Dmitrii KuvaiskiiRedis-SGX: Dmitrii Kuvaiskii
Redis-SGX: Dmitrii KuvaiskiiRedis Labs
 
Db2 Warehouse on Cloud Flex テクニカルハンドブック 2020年3月版
Db2 Warehouse on Cloud Flex テクニカルハンドブック 2020年3月版Db2 Warehouse on Cloud Flex テクニカルハンドブック 2020年3月版
Db2 Warehouse on Cloud Flex テクニカルハンドブック 2020年3月版IBM Analytics Japan
 
Mixed-critical adaptive AUTOSAR stack based on VxWorks, Linux, and virtualiza...
Mixed-critical adaptive AUTOSAR stack based on VxWorks, Linux, and virtualiza...Mixed-critical adaptive AUTOSAR stack based on VxWorks, Linux, and virtualiza...
Mixed-critical adaptive AUTOSAR stack based on VxWorks, Linux, and virtualiza...Andrei Kholodnyi
 
Rootless Containers
Rootless ContainersRootless Containers
Rootless ContainersAkihiro Suda
 
Best Practices of HA and Replication of PostgreSQL in Virtualized Environments
Best Practices of HA and Replication of PostgreSQL in Virtualized EnvironmentsBest Practices of HA and Replication of PostgreSQL in Virtualized Environments
Best Practices of HA and Replication of PostgreSQL in Virtualized EnvironmentsJignesh Shah
 
Curso completo-de-fix-32
Curso completo-de-fix-32Curso completo-de-fix-32
Curso completo-de-fix-32Mário Bassoli
 
Repository and Unit Of Work Design Patterns
Repository and Unit Of Work Design PatternsRepository and Unit Of Work Design Patterns
Repository and Unit Of Work Design PatternsHatim Hakeel
 
Nick Stephens-how does someone unlock your phone with nose
Nick Stephens-how does someone unlock your phone with noseNick Stephens-how does someone unlock your phone with nose
Nick Stephens-how does someone unlock your phone with noseGeekPwn Keen
 
2023年はTiDBの時代!
2023年はTiDBの時代!2023年はTiDBの時代!
2023年はTiDBの時代!Tomotaka6
 
Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility PrincipleBADR
 
[Cloud OnAir] BigQuery の仕組みからベストプラクティスまでのご紹介 2018年9月6日 放送
[Cloud OnAir] BigQuery の仕組みからベストプラクティスまでのご紹介 2018年9月6日 放送[Cloud OnAir] BigQuery の仕組みからベストプラクティスまでのご紹介 2018年9月6日 放送
[Cloud OnAir] BigQuery の仕組みからベストプラクティスまでのご紹介 2018年9月6日 放送Google Cloud Platform - Japan
 
TFF2023 - Navigating Tourism Data Nexus
TFF2023 - Navigating Tourism Data NexusTFF2023 - Navigating Tourism Data Nexus
TFF2023 - Navigating Tourism Data NexusTourismFastForward
 
Object Storage in a Cloud-Native Container Envirnoment
Object Storage in a Cloud-Native Container EnvirnomentObject Storage in a Cloud-Native Container Envirnoment
Object Storage in a Cloud-Native Container EnvirnomentMinio
 
あるRISC-V CPUの 浮動小数点数(異常なし)
あるRISC-V CPUの 浮動小数点数(異常なし)あるRISC-V CPUの 浮動小数点数(異常なし)
あるRISC-V CPUの 浮動小数点数(異常なし)たけおか しょうぞう
 

What's hot (20)

Firestoreでマスタ取得を
効率化するいくつかの方法
Firestoreでマスタ取得を
効率化するいくつかの方法Firestoreでマスタ取得を
効率化するいくつかの方法
Firestoreでマスタ取得を
効率化するいくつかの方法
 
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdb
 
Practical experiences and best practices for SSD and IBM i
Practical experiences and best practices for SSD and IBM iPractical experiences and best practices for SSD and IBM i
Practical experiences and best practices for SSD and IBM i
 
Redis-SGX: Dmitrii Kuvaiskii
Redis-SGX: Dmitrii KuvaiskiiRedis-SGX: Dmitrii Kuvaiskii
Redis-SGX: Dmitrii Kuvaiskii
 
Db2 Warehouse on Cloud Flex テクニカルハンドブック 2020年3月版
Db2 Warehouse on Cloud Flex テクニカルハンドブック 2020年3月版Db2 Warehouse on Cloud Flex テクニカルハンドブック 2020年3月版
Db2 Warehouse on Cloud Flex テクニカルハンドブック 2020年3月版
 
Mixed-critical adaptive AUTOSAR stack based on VxWorks, Linux, and virtualiza...
Mixed-critical adaptive AUTOSAR stack based on VxWorks, Linux, and virtualiza...Mixed-critical adaptive AUTOSAR stack based on VxWorks, Linux, and virtualiza...
Mixed-critical adaptive AUTOSAR stack based on VxWorks, Linux, and virtualiza...
 
Rootless Containers
Rootless ContainersRootless Containers
Rootless Containers
 
Plan 9: Not (Only) A Better UNIX
Plan 9: Not (Only) A Better UNIXPlan 9: Not (Only) A Better UNIX
Plan 9: Not (Only) A Better UNIX
 
Best Practices of HA and Replication of PostgreSQL in Virtualized Environments
Best Practices of HA and Replication of PostgreSQL in Virtualized EnvironmentsBest Practices of HA and Replication of PostgreSQL in Virtualized Environments
Best Practices of HA and Replication of PostgreSQL in Virtualized Environments
 
.Net Core
.Net Core.Net Core
.Net Core
 
Netapp Storage
Netapp StorageNetapp Storage
Netapp Storage
 
Curso completo-de-fix-32
Curso completo-de-fix-32Curso completo-de-fix-32
Curso completo-de-fix-32
 
Repository and Unit Of Work Design Patterns
Repository and Unit Of Work Design PatternsRepository and Unit Of Work Design Patterns
Repository and Unit Of Work Design Patterns
 
Nick Stephens-how does someone unlock your phone with nose
Nick Stephens-how does someone unlock your phone with noseNick Stephens-how does someone unlock your phone with nose
Nick Stephens-how does someone unlock your phone with nose
 
2023年はTiDBの時代!
2023年はTiDBの時代!2023年はTiDBの時代!
2023年はTiDBの時代!
 
Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility Principle
 
[Cloud OnAir] BigQuery の仕組みからベストプラクティスまでのご紹介 2018年9月6日 放送
[Cloud OnAir] BigQuery の仕組みからベストプラクティスまでのご紹介 2018年9月6日 放送[Cloud OnAir] BigQuery の仕組みからベストプラクティスまでのご紹介 2018年9月6日 放送
[Cloud OnAir] BigQuery の仕組みからベストプラクティスまでのご紹介 2018年9月6日 放送
 
TFF2023 - Navigating Tourism Data Nexus
TFF2023 - Navigating Tourism Data NexusTFF2023 - Navigating Tourism Data Nexus
TFF2023 - Navigating Tourism Data Nexus
 
Object Storage in a Cloud-Native Container Envirnoment
Object Storage in a Cloud-Native Container EnvirnomentObject Storage in a Cloud-Native Container Envirnoment
Object Storage in a Cloud-Native Container Envirnoment
 
あるRISC-V CPUの 浮動小数点数(異常なし)
あるRISC-V CPUの 浮動小数点数(異常なし)あるRISC-V CPUの 浮動小数点数(異常なし)
あるRISC-V CPUの 浮動小数点数(異常なし)
 

Similar to Suite Script 2.0 API Basics

Dot Net Fundamentals
Dot Net FundamentalsDot Net Fundamentals
Dot Net FundamentalsLiquidHub
 
Nt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language AnalysisNt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language AnalysisNicole Gomez
 
.NET Core Apps: Design & Development
.NET Core Apps: Design & Development.NET Core Apps: Design & Development
.NET Core Apps: Design & DevelopmentGlobalLogic Ukraine
 
Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideMohanraj Thirumoorthy
 
Angularjs2 presentation
Angularjs2 presentationAngularjs2 presentation
Angularjs2 presentationdharisk
 
D22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksD22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksSunil Patil
 
D22 portlet development with open source frameworks
D22 portlet development with open source frameworksD22 portlet development with open source frameworks
D22 portlet development with open source frameworksSunil Patil
 
Operator SDK for K8s using Go
Operator SDK for K8s using GoOperator SDK for K8s using Go
Operator SDK for K8s using GoCloudOps2005
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notesWE-IT TUTORIALS
 
Typescript language extension of java script
Typescript language extension of java scriptTypescript language extension of java script
Typescript language extension of java scriptmichaelaaron25322
 
Using advanced C# features in Sharepoint development
Using advanced C# features in Sharepoint developmentUsing advanced C# features in Sharepoint development
Using advanced C# features in Sharepoint developmentsadomovalex
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfoliomwillmer
 
Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overviewskill-guru
 
Let’s template
Let’s templateLet’s template
Let’s templateAllenKao7
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2Long Nguyen
 

Similar to Suite Script 2.0 API Basics (20)

Dot Net Fundamentals
Dot Net FundamentalsDot Net Fundamentals
Dot Net Fundamentals
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
Nt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language AnalysisNt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language Analysis
 
.NET Core Apps: Design & Development
.NET Core Apps: Design & Development.NET Core Apps: Design & Development
.NET Core Apps: Design & Development
 
Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's Guide
 
Angularjs2 presentation
Angularjs2 presentationAngularjs2 presentation
Angularjs2 presentation
 
D22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksD22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source Frameworks
 
D22 portlet development with open source frameworks
D22 portlet development with open source frameworksD22 portlet development with open source frameworks
D22 portlet development with open source frameworks
 
Operator SDK for K8s using Go
Operator SDK for K8s using GoOperator SDK for K8s using Go
Operator SDK for K8s using Go
 
.net Framework
.net Framework.net Framework
.net Framework
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notes
 
Typescript language extension of java script
Typescript language extension of java scriptTypescript language extension of java script
Typescript language extension of java script
 
Using advanced C# features in Sharepoint development
Using advanced C# features in Sharepoint developmentUsing advanced C# features in Sharepoint development
Using advanced C# features in Sharepoint development
 
Angular 9
Angular 9 Angular 9
Angular 9
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
 
Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overview
 
Spring boot
Spring bootSpring boot
Spring boot
 
Let’s template
Let’s templateLet’s template
Let’s template
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
 
React inter3
React inter3React inter3
React inter3
 

Recently uploaded

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Recently uploaded (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

Suite Script 2.0 API Basics

  • 1. SuiteScript 2.0 API Netsuite Released 2015 ∼ July 13, 2018
  • 2. Agenda NetSuite at a glance What is SuiteScript API? Key concepts of SuiteScript 2.0 API SuiteScript 2.0 Syntax HelloWorld Script Advantages of SuiteScript 2.0 Drawback Coexistence rules 1
  • 3. Objectives of this presentation Understanding the basics of SuiteScript 2.0 API Explore the key differences between SuiteScript 1.0 & SuiteScript 2.0 2
  • 4. NetSuite at a glance Cloud-based business management software Software as a Service (SaaS) 3
  • 5. Is a JavaScript API that offers a broad range of options for enhancing and extending NetSuite SuiteScript API What is SuiteScript API? 😟 😎 4
  • 7. SuiteScript 2.0 is modular All SuiteScript 2.0 APIs are organized into modules Each module reflects the functionality Concept #1: 6
  • 8. NetSuite modules & objects record searchlog file NS N create({}) save({})load({}) ∼32 modules e.g: N/file ∼… APIs e.g: record.create({}); setValue({}) …({}) Concept #1 (cont’d) 7 Module must be explicitly loaded by a script before using that module’s API
  • 9. Suitescript 1.0 API Organized in a Single global library JavaScript file. Each file gets loaded to every single script regardless of how much API the script use. Suitescript 2.0 API Organized and grouped into the modules Modules are loaded only when they are needed. — based on Asynchronous Module Definition(AMD) Now Before Modular Concept #1 (cont’d) 8
  • 10. Object as Arguments The arguments passed to methods are typically {key:value} objects var myObject = { fieldId: 'greetingMsg', value: 'Hello, World!' }; myRecord.setValue(myObject); myRecord.setValue({ fieldId: 'greetingMsg', value: ‘Hello, World!' }); Concept #2: 9
  • 11. Suitescript 1.0 API Argument list Suitescript 2.0 API Object as argument Now Before ‣ Objects var myObject = { fieldId: 'greetingMsg', value: 'Hello, World!' }; myRecord.setValue(myObject); nlapiSetFieldValue('greetingMsg', 'Hello, World!'); Concept #2 (cont’d) 10
  • 12. Script types and their Entry pointsConcept #3: Script type: SuiteScript 2.0 scripts consist of several script types Each script type is designed for a specific type of situation and specific types of triggering events Entry point: Represents the juncture at which the system grants control of the NetSuite application to the script. Each script type includes one or more entry points that are exclusive to that type 11
  • 13. UserEventScript ClientScript ScheduledScript … Server (execute on the server) Client (execute in the user’s browser) Script types Entry points ✦ beforeLoad ✦ beforeSubmit ✦ afterSubmit ✦ execute ✦ fieldChange ✦ pageInit ✦ Etc… Concept #3 (cont’d) 12 …
  • 14. Suitescript 1.0 API Scripts are not Expressive: - hard to recognize the purpose of a script Scripts are Dependent: - Actions depend on settings done on NetSuite side Suitescript 2.0 API Expressive scripts - automatically detected by NetSuite Independent scripts - No other enhancements needed. Now Before ‣ JSDocs tags ‣ Script types & Entry points function myFunction(){ // logic here } sample_script.js /** * @NScriptType <script_type_name> */ define([], function() { function myFunction(){ // logic here } return {
 <entry_point_name> : <entry_point_function>
 }; }); sample_script.js Concept #3 (cont’d) 13
  • 15. Entry point scripts & Custom module scriptsKey concept #4: Entry point script: The primary script attached on the script record It identifies the script type, entry points, and entry point functions Each entry point script must include at least one entry point and entry point function Custom module script: Is a user-defined script that holds the logic that can be used by other scripts It’s loaded by an Entry point script as a dependency Script type(s) declaration is not required 14
  • 16. Suitescript 1.0 API Suitescript 2.0 APINow Before NS Script record A Script record B script_A.js script_B.jsscript_A.js script_B.js NS Script record A Script record B script_A.js script_B.js ‣ Custom module scripts Concept #4 (cont’d) 15 Same modules used by- many script records
  • 17. Anatomy of an Entry Point Script /** * @NApiVersion 2.0 * @NScriptType UserEventScript */ define(['N/record', 'N/ui/dialog'], function(record, dialog) { function doBeforeLoad() { /* logic of function*/ } function doBeforeSubmit() { /* logic of function*/ } function doAfterSubmit() { /* logic of function*/ } return { beforeLoad : doBeforeLoad, beforeSubmit: doBeforeSubmit, afterSubmit : doAfterSubmit, }; } ); JSDoc tags: Required for an entry point script Entry points: At least one STANDARD entry point is required for a script type Define’s first argument: List of Dependencies and/or Modules 3 2 1 4 Define’s second argument: Callback function 1. 2. 3. 4. Concept #4 (cont’d) 16
  • 18. Anatomy of a Custom Module Script JSDoc tags: NOT Required for a custom module script, but USEFUL. Entry point: At least one USER-DEFINED entry point is required for a custom module Define’s first argument: List of Dependencies and/or Modules required by the script /** * fileName.js * @NApiVersion 2.x * @ModuleScope Public */ define(['N/record', ’N/search'], function(record, search) { function dummySearch() { /* logic of function*/ } return { myDummySearch : dummySearch, }; } ); 3 2 1 4 Define’s second argument: Callback function 1. 2. 3. 4. Concept #4 (cont’d) 17
  • 20. SuiteScript 2.0 Syntax SuiteScript 2.0 syntax == JavaScript Syntax ๏ SuiteScript 2.0 methods takes plain JavaScript key/value object as an input. ๏ All boolean values take true or false (not T or F respectively) ๏ Parameter types in SuiteScript 2.0 must match as those listed in the Docs/NetSuite help ๏ Enumeration encapsulated common constants (e.g; standard record types) ๏ Sublists and column indexing begins at 0 (not 1) … except some rules: 19
  • 21. Let’s create a simple entry point script: ✓ Shows a message on page load /** * @NApiVersion 2.0 * @NScriptType ClientScript * */ define([ 'N/ui/message' ], function(message) { function showMessage() { var msgObj = message.create({ title : 'Greeting', message : 'Hello, welcome!', type : message.Type.INFORMATION, }); msgObj.show(); } return { pageInit : showMessage, }; }); • Q: Why a Script Type is ClientScript ? • Q: What is the name of an entry point in this script ? A: “shows a message on page” (does something on a page) A: “pageInit” • Q: What is the name of an entry point function in this script ? A: “showMessage” 20
  • 23. Some Advantages of SuiteScript 2.0 Enables us to create our own custom modules ✓ Keeps code DRY (Don’t Repeat Yourself): - One module used by many scripts!! ✓ Abstraction : - Later changes don’t affect the deployed script(s) ✓ Possible to add those modules to SuiteApps and expose them to third parties. Modern programming syntax and behavior ✓ Modeled to behave and look like modern JavaScript — e.g: No nlapi/nlobj prefix ✓ Third party JavaScript API support ✓ Updated sublist and column indexing — (begins at 0 instead of 1) Functionality enhancements ✓ MapReduce script type : designed to handle large amounts of data. ‣ automatic yielding without disruption to the script Automatic Dependency management: No need to remember to order of library files 22
  • 24. Other Advantages of SuiteScript 2.0 Easier to catch-up for non-NetSuite programmers Easier to upgrade for future versions: easy as changing the version number Good and solid documentation with adequate examples SuiteScript 2.0 the way forward 23
  • 25. Optional parameters [e.g; setAge(age = 18)] Drawback JavaScript SuiteScript 2.0 Arrow functions [e.g; (a, b) => a + b;] Rest parameters [e.g; avgAge(…age)] Block-scoped variables [ e.g; let age = 18; ] Mismatching of Scripting-language specification: - JavaScript’s new version is ECMAScript 8 (partially supported), but SuiteScript 2.0 currently supports ECMAScript 5 There’s a workaround here!, but haven’t tried it yet!! 24 Ex.:
  • 26. Coexistence rules 1. SuiteScript 1.0 and 2.0 cannot intermix within the same script ‣ You cannot use 2.0 modules as 1.0 Library scripts ‣ You cannot include 1.0 files as 2.0 dependencies 2. The two versions can intermix in the same account, in the same application, and can even be deployed on the same record. SuiteScript 1.0 is still supported. however… 25 …however, SuiteScript 1.0 can be deprecated anytime!!!.