Understanding SUITELET 2.x Basics

What is NetSuite SuiteLet ??

A NetSuite SuiteLet is an amplification in NetSuite SuiteScripts which allows developers to create customized NetSuite pages as well as develop various backend logic. It is a server-side script and works on a request-response model. NetSuite Suitelet has a feature “Available Without Login”, by using this we can access it externally (without NetSuite login).

SuiteLets Type

We have 2 types of SuiteLets in NetSuite

Front-End Suitelets : These SuiteLets are mostly used to create NetSuite look like custom pages that can be created by using UI objects. SuiteScript UI object has elements for creating NetSuite custom page elements like fields sublists, buttons, forms, columns, etc.

Backend Suitelets : Backend Suitelets do not used to create custom pages, it executes backend logic, which can then be utilize by other parts of a custom application. It also provides a service for backend logic to other SuiteScripts.

SuiteLet Working in NetSuite

  1. When user starts an HTTP GET/POST from system generated URL , a web generated object contains the data from client request.
  2. Then script get invoked which give user access to entire server SuiteScript API as well as a web request and web response object.
  3. And NetSuite process the script and returns response to the user. Response can be a string (Free-From-Text), XML, RSS, HTML etc.

SuiteLet Governance Limit

To improve performance, NetSuite uses SuiteScript governance which is based on used units. If the number of allowable usage units is exceeded, the script execution is terminated. Similarly, NetSuite provides a 1000-unit governance limit for SuiteLet for all suitescript versions. There is no additional API or module to reset this for SuiteLets.


SuiteLet Limitations

  • SuiteLets cannot be used for NetSuite integration.
  • SuiteLets cannot be used for web stores. NetSuite online custom forms are available for webstore.
  • Because there are no login requirements for SuiteLet that are available without login, so the data contained within the Suitelet will be less secure.

SuiteLet Examples

Frontend Suitelet : Output

  1. /**
  2. * @NApiVersion 2.x
  3. * @NScriptType Suitelet
  4. */
  5. define([], function() {
  6.     function onRequest(context) {
  7.         var xml = ‘<html><body><h1>Front End SuiteLet Called Successfully</h1></body></html>’;
  8.            
  9.         context.response.write(xml);
  10.         context.response.setHeader({
  11.             name: ‘Custom-Header-Demo’,
  12.             value: ‘Demo’
  13.         });
  14.     }
  15.  
  16.     return {
  17.         onRequest: onRequest  // trigger point
  18.     };
  19. });
  20.  

2. Backend Suitelet : The following sample shows how to fetch search results into a PDF file.

  1. /**
  2.     * @NApiVersion 2.x
  3.     * @NScriptType Suitelet
  4.  */
  5. // This sample shows how to fetch search results into a PDF file.
  6. define([‘N/render’, ‘N/search’], function(render, search) {
  7.                function onRequest(options) {
  8.                var request = options.request;
  9.                 var response = options.response;
  10.                var xmlStr = ‘<?xml version=\”1.0\” encoding=\”UTF-8\”?>\n’+
  11.                ‘<!DOCTYPE pdf PUBLIC \”-//big.faceless.org//report\” \”report-1.1.dtd\”>\n’+
  12.                ‘<pdf lang=\”ru=RU\” xml:lang=\”ru-RU\”>\n” + “<head>\n’ +
  13.                ‘</head>\n’ +
  14.                ‘<body font-family=\”russianfont\” font-size=\”18\”>\n??????? ?????</body>\n” + “</pdf>’;
  15.               var rs = search.create({
  16.               type: search.Type.SALES_ORDER,
  17.               title: ‘SalesOrder Search’,
  18.                id: ‘customsearch_my_second_so_search’,
  19.                columns: [{
  20.                               name: ‘entity’
  21.                               }],
  22.                filters: [{
  23.                               name: ‘mainline’,
  24.                               operator: ‘is’,
  25.                               values: [‘T’]
  26.                               }],
  27.                settings: [{
  28.                               name: ‘consolidationtype’,
  29.                               value: ‘AVERAGE’
  30.                               }]
  31.                  }).run();
  32.                var results = rs.getRange(0,2);
  33.                var renderer = render.create();
  34.                renderer.templateContent = xmlStr;
  35.                renderer.addSearchResults({
  36.                 templateName: ‘BackEnd Suitelet’,
  37.                 searchResult: results
  38.                });
  39.                var newfile = renderer.renderAsPdf();
  40.                response.writeFile(newfile, false);
  41.                 }
  42.                return {
  43.                               onRequest: onRequest
  44.                               };
  45. });

Learn More About SUITELET

To Know more about NetSuite Cloud ERP, feel free to reach us on:

Website:https://saturotech.com/

Email ID: sales@saturotech.com

Contact No: +91 844-844-8939 (& Press 3)

You may also be interested in reading this:

Suite Script 2.0

How to handle Tax Collection at Source (TCS) in NetSuite

NetSuite for Manufacturing Business Processes

Share via
Copy link
Powered by Social Snap