1/149
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Client Script
Client scripts are scripts executed by predefined event triggers in the client browser.
Client Scripts execute on 'Edit' and run on individual forms, can be deployed globally, and are applied to entity and transaction record types.
They can validate user-entered data and auto-populate fields or sublists at various form events.
Entry points: Loading form, Edit/Changing, and on Save
User Event Script
User event scripts are executed on the NetSuite server. They are executed when users perform certain actions on records, such as create, load, update, copy, delete, or submit.
Most standard NetSuite records and custom record types support user event scripts
Entry points: afterSubmit, beforeLoad, beforeSubmit
Map Reduce Script
The map/reduce script type is designed for scripts that need to handle large amounts of data.
They provide a structured framework for processing a large number of records or a large amount of data and are best suited for situations where the data can be divided into small, independent parts.
Either Map or Reduce functions are required to execute. Both are not necessarily required.
Map Reduce Scripts are not best for long complex functions that need to be enacted.
Map Reduce Scripts permit yielding and leverage multiple jobs to execute.
Scheduled Script
Scheduled scripts are server scripts that are executed (processed) with SuiteCloud Processors. You can deploy scheduled scripts so they are submitted for processing at a future time, or at future times on a recurring basis.
Scheduled scripts are assigned one job and one processor for execution. It does not support yielding, unlike M/R.
Best not to be used with large amounts of data. Instead, use M/R script for large data.
Workflow Action Script
- One entry point, onAction(scriptContext)
- Useful because actions on sublist fields are not available through the workflow manager
- Execute complex logic beyond built-in action
Suitelet Scripts
Suitelets are extensions of the SuiteScript API that give developers the ability to build custom NetSuite pages and backend logic.
Suitelets are server-side scripts that operate in a request-response model. They are invoked by HTTP GET or POST requests to system generated URLs
Front End Suitelet
Use UI objects to create custom pages that look like NetSuite pages. SuiteScript UI objects encapsulate the elements for building NetSuite-looking portlets, forms, fields, sublists, tabs, lists, and columns
Backend Suitelet
Do not use any UI objects and execute backend logic, which can then be parsed by other parts of a custom application.
Backend Suitelets are best used for the following purposes:
- Providing a service for backend logic to other SuiteScripts.
- Offloading server logic from client scripts to a backend
Suitelet shipped without source code to protect sensitive intellectual property.
RESTlet
A RESTlet is a SuiteScript that you make available for other applications to call. It can be called from either an external application or from another script within NetSuite. A RESTlet executes only when it is called and in some cases, returns a value to the calling application.
RESTlets can be useful when you want to bring data into NetSuite from another system, or if you want to extract data from NetSuite. RESTlets can also be used in combination with other scripts to customize the behavior of a page within NetSuite
Entry Point: Get, Delete, Put, Post
Portlet Script
Portlet scripts are run on the server and are rendered in the NetSuite dashboard. The following portlet script types are supported
Simple form
Inline HTML
Simple List
Dashboard SuiteApp Portlet
Entry Point: render(params)
Mass Update
Mass update scripts allow you to programmatically perform custom updates to fields that are not available through general mass updates. Mass update scripts can run complex calculations, as defined in your script, across records.
Mass update scripts are started on demand, and you cannot prioritize them or schedule them to run at specific times. If you want your script to run at a specific time, consider using a scheduled script or map/reduce script instead of a mass update script
Bundle Installation
Bundle installation scripts are specialized server scripts that perform processes in target accounts as part of a bundle installation, update, or uninstallation. These processes include setup, configuration, and data management tasks that would otherwise have to be completed by account administrators.
Every bundle can include a bundle installation script that is automatically run when the bundle is installed, updated, or uninstalled. Each bundle installation script can contain triggers to be executed before install, after install, before update, after update, and after uninstallation.
Log Levels
Debug: For scripts in testing mode. Selecting this level will show all log messages (debug, audit, error, and emergency).
Audit: For scripts going into production. Selecting this level will show the events that have occurred during the processing of the script (for example, "A request was made to an external site.").
Error: For scripts going into production. Selecting this level will show only unexpected script errors.
Emergency: For scripts going into production. Selecting this level will show only the most critical errors in the script log.
SuiteScript 2.1 Server-side Debugger
- Only debugs 2.1 Scripts
- Uses Chrome Devs Tools
- Use Break Points to stop the execution of scripts
Types: Scheduled scripts, Suitelets, User event scripts
Client Script Debugger
Client scripts are executed on the client browser based on how they are deployed. To debug a client script, use the debugging tools available on your browser. SuiteScript supports several browsers:
Google Chrome (preferred)
Mozilla Firefox (preferred)
Microsoft Edge
Apple Safari
Form & Record level scripts should both be debugged
RESTlet Debugger
- Launch and debug via SuiteCloud IDE extension
- Debug a launched script, be sure to remove HTTP header
n/log
- Log Object is loaded by default for all script types
- Used for logging script execution details
- Log messages appear on the Execution Log tab of the script deployment.
- Governed by NetSuite
- Max logging given any 60-minute
- 100,000 log object method calls across all scripts
n/error
Use try-catch statements to abort script execution.
- Create Error
- Throw Error
- Handle Error
Log errors using N/log module
User Event unsupported
n/record
Use this module to:
- create
- delete
- copy
- load
- make changes to record
require Function
Used for On-demand Bugging
The require function is a global object that implements the require() Module Loader interface for SuiteScript 2. x. When NetSuite executes the required function, it executes the callback function and loads the dependencies when they are needed.
This function executes asynchronously on the client and synchronously on the server.
define Function
The first argument is a list of any dependencies, such as standard SuiteScript 2.x Modules. These modules are loaded when the script executes.
The second argument is a callback function. The callback function must include a return statement that identifies at least one standard or custom entry point. The entry point must be associated with an object that is returned when the entry point is invoked. In most use cases, this object is a function.
JSDoc Annotations
/**
* Creates a file
* @param {string} name - file name
* @param {string} fileType - file type
* @param {string} contents - file content
* @returns {Object} file.File
*/
JSDoc also includes its markup language, which is made up of JSDoc tags. These tags are prefaced with the @ symbol. The JSDoc tags are added to the comment blocks, and they are used to specify the various entities of a JavaScript file (for example, @param).
Document Object Model (DOM)
SuiteScript does not support DOM module. NetSuite UI access should be leverage using SuiteScript API
Asynchronous Module Definition (AMD)
Organize code and design patterns into modularized code
- Async Loading
- Dependency Management
- Dynamic Loading
- Browser Compatibility
Custom Modules
With SuiteScript 2. x, you can create custom modules (including third-party, AMD, and non-AMD modules). This supports modular and well-structured organization of code that is easier to read and modify. It also lets you build and access additional, customized API functionality.
- Custom API's
- Expose modules to 3rd parties
- Import third-party API
- Organize business logic, separate from utilities
SuiteScript Best Practices
Script Structure and Organization: Break code into smaller, manageable modules. Use meaningful names and organize scripts logically for easy maintenance.
Performance Optimization: Minimize script execution time by reducing unnecessary operations and optimizing loops and queries.
Error Handling: Implement robust error handling to catch and manage exceptions, ensuring scripts fail gracefully.
Governance and Resource Management: Be mindful of NetSuite governance limits. Efficiently use system resources and cache data when possible.
Security: Follow security best practices to prevent vulnerabilities, such as avoiding hardcoded credentials and validating user inputs.
Version Control: Use versioning for scripts to track changes and revert if needed, ensuring a reliable codebase.
Testing and Debugging: Thoroughly test scripts in a sandbox environment before deploying to production. Leverage debugging tools for efficient troubleshooting.
Documentation: Maintain comprehensive documentation for code, explaining functionality and usage for better collaboration and understanding.
Record-level deployment
- Applies script globally on one or more record types
- Runs on all forms associated with that record type
- Cannot limit the script to one form
- Can be used on forms/ lists generated by Suitelets
- Upload script file to file cabinet
- Must create Script Record and Script Deployment
Form-level deployment
- Attach the script to a custom form associated w/ record type
- Only runs when the custom form is used
- Cannot limit the audience for a form-level script
- Attach the script to the custom entry form
Script Parameters
- User changeable fields that affect the execution of the script
- Can pass values to other scripts
- On Script deployment record
N/ui Modules
- N/ui/serverWidget: contains UI components to work with
- N/ui/message: display and manage messages at the UI level
- N/ui/dialog: create modal dialog boxes for options/alerts
- message & dialog can execute on client scripts
N/currentRecord
- Use client scripts to interact w/ currently active record
- Always in Dynamic mode
- Does not permit the editing of subrecords, but can be retrieved
Online Forms
- HTML documents used for customer/ case forms/ marketing
- Uses
- Uses tags
- Can tag NetSuite fields
- Can Pass parameters or track URLs from forms
Scriptable Templates
- use a combo of HTML and FreeMarker code
- Add dynamic variables to your HTML
N/url
- Determine URL navigation paths within NetSuite or format URL strings
- Retrieve the URL of a relative record
- Retrieve the domain for calling a RESTlet
N/redirect
- customize navigation by redirect URL internally or externally
- doesn't support beforeSubmit or asynch afterSubmit events
- redirect to Suitelet or a NetSuite record, or saved search
context.UserEventType
- considered an entry point
- holds the string values for user event execution context
- beforeLoad, beforeSubmit, and afterSubmit entry points
- consists of values such as CREATE, TRANSFORM, EMAIL
SuiteScript Browser
- records generally available for use in SuiteScript
- available fields, sublists and search filter fields for certain records
- Use Records Browser for the most recent release
N/record
- work with NetSuite records
- create, delete, copy, load or make edits to records
- default values
record.create - copy, transform, load
SuiteScript Member Types
- Object
- Method
- Enum
- Property
Subrecords
- always represented by a single field on a record
- can exist either as a body or sublist field
- dynamic/ standard mode
N/file
- use module to work with files within NetSuite
- upload files to the NetSuite file cabinet
- send files as attachments without uploading them to FC
- File.getReader() has a 10MB limit
N/search
- create and run on-demand saved searches results
- paginate search results, suitable for large results
- search for single record
- search for duplicate records
- return a subset of records that match filter criteria
N/query
- lets you create and run queries using Analytics API
- query using Records Catalog
- create conditions, formulas, joins, and page results
N/datasets
- create a new datatset, load an existing dataset
- list existing datasets, or saved datasets
- available for server script only
- analogous to executing a query definition using N/query
N/datasetLink
- link datasets
- when linked, you can use both datasets in your workbooks
N/workbook
- create a new workbook
- load an existing workbook
- list all existing workbooks
n/task
- create tasks and place them in the internal NS task queue
- submit the scheduled script
- run a m/r script
- Import CSV files
- merge duplicate records
- run async searches, queries, SuiteQL, and workflows
- server script only support
N/email
- use module to send email messages from within NetSuite
- regular, bulk and campaign emails
- promises works with n/email
- supports client and server
N/http
- use to make http calls from server or client scripts
- client scripts, use to make cross-domain http requests
- does not accept https protocol
- supports CRUD
N/https
- manage content set to 3rd party using https calls
- make https calls from client and server
- does not allow http protocol
- loads n/crypto and n/encode module
- Use TLS 1.2 for https requests
- Use TBA or OAuth 2.0 for credentials
N/sftp
- to manage folders and upload/ download files from external SSH file transfer servers (SFTP)
- NetSuite does not provide SFTP server functionality
- To/from transfer must originate from SuiteScript
- SSH Keys to establish an SFTP connection
- Server script support
N/runtime
- View runtime settings for a script, session, or user
- Use module to set a session key or to see if a feature is enabled
- Get script parameters = Script.getParameter(options)
- Check feature = runtime.isFeautreinEffect(options)
- Client and server support
N/config
- access NetSuite configuration settings
- config.load(options) = loads record object configuration
- server script support
N/currency
- to work with exchange rates within NS account
- find exchange rate between two currencies based on date
- currency format is handled by N/format
- client and server support
N/format
- parse formatted data into strings and convert strings into a specific format
- format data according to personal preferences page
- client and server support
N/recordContext
- get all available context types of a record
- create conditional statements within a script to change behavior based on the context set
- get Localization Value
- client and server support
N/translation
- interact with NS translation collections programmatically
- read-only access
- translate content to local language
- client and server support
Map/Reduce entry points
- getInputData (inputContext)* required
- map (mapContext) optional
- reduce (reduceContext) optional
- summarize (summaryContext)* required
getInputData
- purpose is to generate input data
- reference object that represents data, i.e. record or search
- can use JSON.stringify()
map(mapContext)
- the logic of your map function applied to each key/pair value
- One key/value pair is processed per function invoke
- Pass to the reduce stage
reduce(reduceContext)
- reduce logic applied to each key and list value
- shuffle stage, when using map, sorts data from map by key
- logic lets you save data to pass to summarize stage
summarize(Context)
- holds statistics regarding the execution of script
- logic is applied to the result set
- display results in concurrency, seconds, usage, yields etc.
Workflow States
- represents a specific step or phase within a workflow
- each state can have conditions and actions
- conditions that must be met
- actions to be performed, such as sending emails or adding buttons
Workflow Actions
- specific tasks performed by the workflow instance based on the properties of the record
- use actions to manipulate fields on a record or create new records
- trigger determines when an action executes
- can execute based on a condition
Client Action Triggers
Before User Edit
Before Field Edit
After Field Edit
After Field Sourcing
Before User Submit
Server Action Triggers
On Entry
On Exit
Before Load
Before Submit
After Submit
Scheduled
Custom Workflow Action
Functionality of a custom action is defined with SuiteScript in a workflow action script
Workflow State Fields
- apply to a single state in a workflow
- get and set data within a workflow, similar to workflow field
- store unique value for each record per instance the workflow runs on
Workflow Conditions
used on workflow
- initiation
- actions
- transitions
Can be basic field value, comparisons, exp, or formulas
Workflow Transitions
- moves the record in the workflow into another state
- a state can contain multiple transitions, w/ multiple conditions
- triggers determine when a transition executes
Transition Trigger Types
- Entry
- Before Record Load
- Before Record Submit
- After Record Submit
- Scheduled
- Blank
*Exit doesn't appear to be supported
Workflow Formulas
- can defined in conditions for:
workflow initiation, actions, and transitions.
- build formulas based on the fields for the workflow base record and joined records
- calculated dynamically when the workflow instance runs
- SQL functions when executes on a server trigger
- JS/ SuiteScript API when action executes on client trigger
Workflow Saved Searches
- use saved search on an action as a condition
- doesn't execute unless the record is returned by search
- when triggered, NS runes the saved search immediately
- use server trigger w/ action and saved search condition
- doesn't respect client trigger
Scheduled Workflow Actions
- scheduled actions only execute after the record enters the state for the action
Lock Record Action
- action to lock record for workflow instance when the record is in state
- does not have any additional parameters
- the default trigger type is Before Record Load
Add Button Trigger
Supports the following server-side trigger
- Before Record Load (default)
- On Entry
- On Exit
Do Not Exit Workflow
- non-exiting states to execute a workflow indefinitely
- use for single state workflows
- good for approval based workflows
Execution Context Filtering
- use to ensure that your scripts or workflows are triggered
- context types that define if workflow is executed because of an action, RESTlet, or integration
Workflow Event Types
- define workflows to initiate or execute actions and transitions on specific event types
- such as create, edit, email etc.
Sublist Action Groups
- execute actions on sublist lines for transaction records
- can be executed on all server triggers
- they cannot be executed on client triggers
Sub-Workflows
- use when you have multiple workflows you want to process
- sequential processing
- parallel processing
- parallel approvals
- separate client and server trigger action executions
- can be async or synchronous
Old Values in Workflow
- can change values of a record when the workflow runs
- reference pre-edit values on Before/After Record Submit
- values that existed in the DB before saving the changed record
Set Field Value Action
- set the value of a record field in a workflow instance
- action to set any field value on a record form including multi and date fields
- field, static value, date, from field, formula
- before Record Load server trigger doesn't apply, use Client to override existing values on record
Workflow Execution Log
- tracks all actions and transitions that execute on record
- use to debug and troubleshoot
- when in testing mode, it's enabled by default
- when in release mode, it must be enabled manually
- keep logs can potentially slow down record performance
- Deleted every 60 days
Advanced PDF/HTML Templates
- More advanced editing than basic form layouts
- used to format email and printed versions of transactions
- can produce either PDF or html output
- can use SuiteScript to make advanced customizations
BFO
- Big Faceless Organization
- Java application that converts XML to PDF
- uses
FreeMarker
- Java-based library used to generate text outputs based on templates and dynamic data
- Uses interpolations to include NetSuite data in templates
- expression such as, ${record.entity}
- reference fields, sublists, and other lists
- Scalars: field values from Netsuite records
- Hashes: variables that act as directories. Records and sublists
- Sequences: containers that store a list of variables. Retrieve Sublist values
N/render
Module for:
- printing
- PDF Creation
- form creation from templates
- email creation from templates
- server script support only
FreeMarker w/ BodyFields
Syntax = ${object.fieldId}
Example = ${record.entity}
Record = object
Entity = fieldId
FreeMarker w/ Sublists
uses the #list declaration
<#list record.item as item>
${item_index} ${item.itemName@label} ${item.itemName} --- ${item.amount}
Sublist Syntax
${item.item@label}
${item.id}
${item.item}
${item.quantity}
FreeMarker w/ Joins
Syntax = ${record.related_record.fieldId}
Example = ${record.item.salesdescription}
<#list results as salesOrder>
${salesOrder.customer.phone}
FreeMarker w/ Formatting
Standard Field Formatting:
ex: ${record.custbody_show_int} = 1,234 Output
Use ${nsform*()} method for custom vairables
ex: ${nsformat_url ("http://example.com")} = clickable link
Custom DataSource for Templates
Use the N/render module and combine data from an outside source
- JSON/XML is handled as a string
-
- JSON is converted to XML for printing
FreeMarker Locale
- Printouts are localized based upon user/ customer setting
- Alter content across forms
<#if .locale == "en_US">
<#elseif .locale == "es_FR">
Execution Context
- Tell the system how or when an SS or SF is triggered to run
- Set on Context Filter tab or Programmatically on Script
- Will not execute if the context is not set
- can use runtime.ContextType in the script to execute context
N/ui/message
- display non-intrusive message or alerts to users
- doesn't necessarily require user input or interaction
N/ui/dialog
- present a modal or pop-up window that requires user interaction or input before proceeding
- contains forms, prompts, or critical messages
N/util
- Util Object loaded by default for all script types
- use to access methods that verify object and primitive types manually
- possibly used for logging/ debug
- iterates over each member in Objects/ Arrays
- copies source object to destination objects
- Otherwise, use a boolean to return t/f about JS functions
SuiteBuilder Source List
- select the record type you want to source from
- can select multiple source lists for your custom records
SuiteBuilder Source From
- select the field you want to include information from
- must select a Source List first
- field type must match the type selected in Type field