N/Runtime Module in NetSuite

N/Runtime Module in NetSuite

In this tutorial of netsuite solution provider we are telling about the N/Runtime module of SuiteScript 2.0 and its usage. Firstly Load the runtime module when you want to view runtime settings for the script, the session, or the user. You can also use this module to set a session key and to see whether a particular feature is enabled in your account.

Feel free to reach out netsuite solution provider, for  netsuite implementationnetsuite consultation , netsuite customizationnetsuite Support and  netsuite Training .

Some Important Objects and there usage

runtime.Script  (Encapsulates the runtime settings of the currently executing script.)

runtime.Session (Encapsulates the user session for the currently executing script.)

runtime.User (Encapsulates the properties and preferences of the user currently executing the script.)

runtime.getCurrentScript() Returns a runtime.Script object that represents the currently executing script.

runtime.getCurrentSession() Returns a runtime.Session object that represents the user session for the currently executing script.

runtime.getCurrentUser() Returns a runtime.User object that represents the properties and preferences of the user currently executing the script.

Script.getParameter(options) Returns the value of a script parameter for the currently executing script.

Script.getRemainingUsage() Returns the number of usage units remaining for the currently executing script.

**

 * @NApiVersion 2.x

 * @NScriptType Suitelet

 */

//Write user and session information for the currently executing script to the response.

define([‘N/runtime’], function(runtime) {

    function onRequest(context) {

        var remainingUsage = runtime.getCurrentScript().getRemainingUsage();

        var userRole = runtime.getCurrentUser().role;

        runtime.getCurrentSession().set({

            name: ‘scope’,

            value: ‘global’

        });

        var sessionScope = runtime.getCurrentSession().get({

            name: ‘scope’

        });

        log.debug(‘Remaining Usage:’, remainingUsage);

        log.debug(‘Role:’, userRole);

        log.debug(‘Session Scope:’, sessionScope);

        context.response.write(‘Executing under role: ‘ + userRole

            + ‘. Session scope: ‘ + sessionScope + ‘.’);

    }

    return {

        onRequest: onRequest

    };

 });

This script sample uses the define function, which is required for an entry point script (a script you attach to a script record and deploy). You must use the require function if you want to copy the script into the SuiteScript Debugger and test it.

Reference : netsuite.com, netsuite help  and netsuite guide.

Feel free to reach out netsuite solution providernetsuite implementationnetsuite consultation , netsuite customizationnetsuite Supportnetsuite Training  contact us at: Email : [email protected]

Facebook : https://www.facebook.com/Smiling-Coders-Netsuite-Training-Implementation-and-Support-1591053827660082/

Linkedin : https://www.linkedin.com/company/netsuite-academy/


Log out of this account

Leave a Reply