Plugins in Netsuite
First create plugin type then create plugin implementation
then use ‘N/plugin’ module
var addnum= plugin.loadImplementation({
type:’customscript_add_numbers’
});
to load main plugin
var addnum2 = plugin.loadImplementation({
type:’customscript_add_numbers’,
implementation: ‘customscript150’
});
to load plugin implementation
Debugger
To debug existing you should be the owner of the script and status should be testing
Client script can not be debugged on script debugger
Debugger shares the same database as production.
SuiteCloud Processors
-
Good for load balancing and script prioritization. Suitecloud processors offer automatic load balancing and script prioritization.
-
Ability to automatically increase a job priority
-
Jobs that are waiting for execution for a certain number of hours, four hours for example, to get a higher priority and a chance of execution instead of staying in the queue until all the other higher priority jobs have finished executing.
-
By default, accounts are given two processors but can be upgraded to up to 50 through a suiteCloud plus license
Setup -> Company -> suiteCloud processors
Scripting -> priority settings
Map Reduce Script
Map stage is distributed, so if search has 1000 results then map stage will run 1000 times and group the data using context.write
Grouping is based on key, so if key is 100, it will create 100 groups and put repeated value of key in array
This grouped data is later passed on to the reduce stage, where you can iterate over the grouped data and do further processing.
Concurrency limit is the number of processors being used at a time in map reduce.
Buffer size is the number of results that can be processed at a time.
Automatic Yielding
Map reduce script executes in 5 stages
-
GetInputData
-
Map
-
Shuffle
-
Reduce
-
Summarize
Shuffle – If we are using reduce then, shuffle gets data from the map; otherwise it directly calls the summarize stage. If the map is not defined it gets data from the getInputData stage.
Map Reduce Script
Advantages of map reduce script over scheduled script
-
Distributed processing
-
Automatic governance handling
-
Custom time based yielding
-
Summary reporting
-
Built in provision for error handling
There are two kinds of governance limits in map reduce
Soft Limit
Hard Limit
Soft limit prevents a map reduce script to take more than 10000 units but instead of throwing error and stopping script execution. Script is automatically yielded to process later.
Hard Limit stops the execution of script for example map reduce is limited to processing 200 mb at a time
A saved search can be directly returned to the system.
Setting the buffer to higher allows more key/value pairs at the same time.
Multiple User Event Script
A user event script can not call another user event script, this helps prevent infinite loop scenarios.
If there are multiple use event script deployed to a single record then after one finishes execution then only another starts
When we save a record, before submit events executes first across the scripts, followed by all after submit events
User event scripts run when records are loaded, created or updated from other scripts but not from other user events .
We can turn off calling the user event script on csv and suite talk.
You can not execute other user event script deployed on other record from one user event script
Means that a user event script can not call other user event script
Client Side Validation
If you are writing any business validation on the client side , be sure that anybody can access it through browser conser so it is always better to put validation on server script like user event script.
There are two ways to put client side validation on server side
-
Put the validation in a user event script in before submit
-
Put the validation in a suitelet then call the suitelet with client side script
Risks of implementing only client side validation
-
May behave differently across browsers and their versions
-
Exposing business algorithm that should not be made public
Deployment Configuration across script types
You can deploy the same script on multiple records by knowing the execution context (to check if the script is running as a client, user event , suitelet )
Or by environment type (Sandbox or production) using N/runtime module
Company Pref, User Pref and Script Param
Script Parameters help remove hard coded values.
Company Preference – Global to entire organization. Can be changed from setup -> company -> general Pref , can only be modified by the administrator
User Preference – Value is specific to each Netsuite user . Home -> set Pref
Blank – Parameter value can be set on script deployment page
To use script parameters, use runtime.getCurrentScript , script parameter value can also be overridden while calling one script from another using N/task module.
Workflow
3 Fields of Workflow
Record Fields – Accessible to any workflow
Workflow Instance Fields – Accessible to Specific workflow
State Fields – Accessible to specific state
Scheduling A Workflow
Scheduling a workflow
Scheduling a Transition
Scheduling a Action
Formula in Workflow
In current version workflow formula is still using suitescript 1.0
There are two types of formula that can be used
-
SQL Formula
-
SuiteScript 1.0 Formula
If workflow is running in server side like after record submit then use SQL formula only
If workflow is running in client side like before user edit the you can use client script formula
Use double pipe to contact strings
When to Use Workflow Action Script
-
It is same as custom workflow actions
-
Allows additional automation not supported by standard actions
-
Complex computational logic using javascript and suitescript api
-
Update a sublist except for item sublist
Lock record action will automatically stop working once the condition is not met
To keep running the lock record action
Mark Do not exit workflow to True
Do not use transition on before record load when you have button
I.e execute on approve button
Entry and Exit are server triggers not client
Suite Bundler
runtime.isFeatureInEffect({feature: ‘ISSUEDB’});
This can be checked in the Before Install Method.
How suiteBundler Handles Collisions ?
By Script ID
A sandbox refresh will delete all the bundles in it
Yes , unless the bundles were installed in production from sandbox before the refresh
Suite Talk
WSDL comes out each Netsuite release that is twice a year. SuiteTalk End point versions are supported for a minimum of 3 years.
SuiteTalk Authentication Methods
There are 3 types of Authentication methods available for suitetalk
-
Login Operation using session based authentication
-
With Passport object in header of request (Request Based Authentication – login information is sent on each request)
-
Token based authentication (Can be used for both request and session based authentication )
For session based authentication concurrency limit is 1 , need to upgrade to suitecloud plus
For request based authentication login information is sent on each request
TBA can be used for both session and request based authentication. It is more secure since tokens are transmitted instead of username / password.
Connecting using TBA exempts from password expiration or PCI compliance
Concurrency is now managed on per account basis instead of per user basis. SuiteCloud plus upgrade adds 10 to account
For session based authentication standard license accounts can have only 1 concurrent connection. If another concurrency is made using the same login operation , a concurrency error will be thrown.
SuiteCloud plus upgrade needs to be purchased to allow concurrency.
Data Center Agnostic Integration
private void setDataCenterUrl(String accountId)
{
DataCenterUrls dataCenterUrls = _service.getDataCenterUrls(accountId).dataCenterUrls;
String webServiceUrl = dataCenterUrls.webservicesDomain;
_service.Url = webServiceUrl + “/services/NetSuitePort_” + netsuiteAccountVersion + “?c=” + accountId;
}
Search Techniques
Basic Search
in SOAP web services a basic search tends to increase the search response time.
-
Basic Search. No joins in criteria or results.
-
Joined Search. Joins in criteria. No joins in results.
-
Advanced Search. Joins in criteria. Joins in results. Specify exact set of result columns.
Impact of script and workflows on integration
User event script will run during suitetalk operation
Efficient Data Synchronization
External Id can be assigned at the time of add or update operation in suitetalk.
External id acts as a foreign key in Netsuite
Account Specific Customization
Suitetalk WSDL supports custom records and custom fields. WSDL is not regenerated based on account customization.
Synchronous and Asynchronous Web Services
SuiteBuilder
Default access level can be used to hide a field under access tab/
Formula can be used under validation and defaulting
Sourcing and filtering can be used to source fields from list (Customer name of sales order is a list type, selecting that source list , populates phone number from custom record )
To get list of all the invoice of a customer , use sourcing and filtering only
List record type is transaction. Source List is entity and filter transaction by entity
For standard record optimistic locking is always enabled but for custom record, it can be disabled.
This is also called record locking behaviour where the same instance of record can not be saved at two different places if one is already saved. It will throw an error as the record has been changed.
Permissions can be set under permissions subtab in a custom record. Permission can be set by role and by level like view create edit full
Role is mandatory for setting permissions .
Field level permission can be set on access subtab
Default access level field by setting None, view , edit
Permissions can also be set by
Role
Department
Subsidiary
Role and Access level are mandatory field
Deleting, Inactivating custom record types
If you delete a record , all the traces of the record are deleted from the database and can not be recovered. It is not recommended to delete a record.
Inactive a record -> Netsuite hides all the references to the record but it remains in the database
ALLOW DELETE OF LIST/RECORD VALUES?
Prevent and Return Error
Allow and Set Depende… Field Values to Null
If a field references another list / record and that list record is being deleted then we have 2 options under allow delete of list/ record values
-
Prevent and return error
-
Allow and set dependent field values to null
SuiteAnalytics
While loading a search , search id should be correct and there should be proper permission.
Page size can also be set from web services preferences
SearchMoreWithId is used with request level authentication where as SearchMore is used with session based authentication
Design Fundamentals
To make a role only web services role.. Just check this
Authentication Methods in Netsuite
Leave a Reply