Category Archives: SuiteScript 2.0

USER EVENT SCRIPT 2.0 TO LOAD A RECORD, READ IT’S VALUE AND SET A FIELD VALUE

Below code loads a sales order, reads it’s sublist values and sets value of a custom field.

/**
 *@NApiVersion 2.x
 *@NScriptType UserEventScript
 */
define([‘N/record’,’N/log’], // modules used
    function(record,log) {
   
        function afterSubmit(context) {
            if (context.type !== context.UserEventType.DELETE)
            {
           
                     var rec_id

Read the rest

HOW TO CREATE SUITELET ASSISTANT IN NETSUITE?

Creating a suitelet assistant involves the following steps:

1) Create the assistant.

2) Create steps.

3) Attach client script to validate data on page init, field change, save ( when user clicks on next or finish) or any other trigger function supported by client script.

4) Build pages for each step. (Get Function)

5) Set values for fields

6) Set up the action when user clicks on next, cancel, back or finish. (Post function)




1)

Read the rest

WHY CLIENT SCRIPT DOESN’T EXECUTE SOMETIMES IN NETSUITE? – NETSUITE ACADEMY

Client script sometimes executes using old code and not the updated code. To resolve this, cache needs to be cleared. Cache can be cleared Once cache is cleared from the browser, you can login to the account again and execute the code. Now, the latest version of the code will get executed.

-Netsuite Academy

Read the rest

USING CASE (IF AND ELSE) IN NETSUITE SAVED SEARCH- NETSUITE ACADEMY

While creating a saved search in Netsuite, you want encounter a situation where you want have to display a value depending on some conditions. Such scenarios can be implemented by using sql CASE syntax in the formula field. For eg, in a transaction search, if you want to display a value depending on the transaction type, then you can add a formula text field in coulmn and use CASE as given below:

CASE WHEN {type}=’Invoice’

Read the rest

Work Around the 1000 Row Limit Returned by Saved Searches in Netsuite

nlapiSearchRecord can return only upto 1000 rows. But there is a work around to retrieve more than 1000 rows. This can be done by first sorting the result based on internal id and then using while loop and use concat method to get all results by internalid number as a filter inside the while loop. The sample code is given below:

var filters = new Array();

filters[1] = new nlobjSearchFilter(‘mainline’,null,’is’,’T’);

var columns = new Array();
Read the rest

Resolve Netsuite Scripting Error “Cannot read property “length” from null”

One of the common errors while searching a record using script is  “Cannot read property length from null”. This error occurs when you try to get length of search record object which returns a null value.
Length method can be used only if search record API returns some value. If it returns null, then length method should not be used.

For eg. below code will return a error if search record gives no result-

var results

Read the rest

HOW TO GET THE TYPE PARAMETER OR RECORD ACCESS MODE IN CLIENT SCRIPT SAVE EVENT?

The Save Record event on a Client-side script does not have the ability to determine the value of the ‘type’ parameter or Access Mode (create, copy, edit) of a record unlike the Page Init event. The alternative is to make use of a global variable that stores the type from page init function and can then be accessed from save function.


var access_mode = ”; // global variable

function clientPageInitl(type){

access_mode = type; // to read
Read the rest

SCRIPT TO ENCRYPT A FILE IN NETSUITE

HOW TO ENCRYPT A FILE IN NETSUITE USING SCRIPT? – NETSUITE ACADEMY

Netsuite scripting provides the ability to encrypt any file stored in file cabinet.

Feel free to reach out netsuite solution providernetsuite implementationnetsuite consultation , netsuite customizationnetsuite Support, netsuite Training  

You would need the file id for this purpose. This file id can be hard coded or obtained using search as per the requirement. The default algorithm
Read the rest