Netsuite Portlet Script

Hi There,

Netsuite provides ways to customize dshboard and add sections to it using saved search etc.
If you want to create a dashboard with a complex logic, data from multiple record etc then
Portlet Script is correct option.
Portlet scripts are server side script and rendered in netsuite dashboard.
Every Postlet type use some api to add features to Portlet , you can add all server side modules
in addition to portlet specific apis.

Portlet Script Types:

1. Simple Form :- This type of portlet script is used for creating form where you can add record-level
client side script also to implement validation.
Example: you can submit data from this form to other form.
While creating Submit Button , define URL.

Simple Form Portlet Object Members:
    Portlet.addField(options) : To use field into protlet use addField.
    Portlet.setSubmitButton(options) : To use submit field use setSubmitButton.
    Portlet.clientScriptFileId : Use this to add Client side validation to form.
    Portlet.clientScriptModulePath : This is used to add Modular path (as above was used to define id).
    Portlet.title : This is use to define title for portlet.

/**
 *@NApiVersion 2.x
 *@NScriptType Portlet
 */
define(['N/search'],
    function(search) {
        function ngForm(params) {
            var portlet = params.portlet;
            portlet.title = 'Netsuite Guru Form';
            var fld = portlet.addField({
                id: 'custpage_ng',
                type: 'text',
                label: 'NG Text'
            });
            fld.updateLayoutType({
                layoutType: 'normal'
            });
            fld.updateBreakType({
                breakType: 'startcol'
            });
            portlet.setSubmitButton({
                url: 'yourURL',
                label: 'Submit',
                target: '_top'
            });
        }
        return {
            render: ngForm
        };
    });
   
   
Inline HTML:- This type of portlet is used to display freeform html.
Example: You can get data from other records, mix with HTML and show it on Inline HTML portlet.

Inline HTML Portlet Object Members:
 Portlet.html : Add HTML to protlet using html property.
  Portlet.title : This is use to add title.

/**
 *@NApiVersion 2.x
 *@NScriptType Portlet
 */
define([],
    function() {
        function ngInlinePage(params) {
            params.portlet.title = 'Inline Portlet';
            var content = '<td><span><b>On the way to become #1 Blog.</b></span></td>';
            params.portlet.html = content;
        }
        return {
            render: ngInlinePage
        };
    });   


Links and Indents— A portlet that consists of rows of formatted content.
Example: If you have developed an app for Netsuite, you can
add important links using this portlet. If you have page to set preference,
page to trigger action etc add link here.

Links and Indents Portlet Object Members:

 Portlet.addLine(options) : Add line to portlet
  Portlet.title : add title to portlet.


*@NApiVersion 2.x
 *@NScriptType Portlet
 */
define([],
    function() {
        function ngLinks(params) {
            var portlet = params.portlet;
            portlet.title = 'NG App Links';
            portlet.addLine({
                text: 'Read our Blog',
                url: 'https://netsuiteguru.blogspot.com/p/netsuite-tutorial.html'
            });
            portlet.addLine({
                text: 'Contact Us',
                url: 'https://docs.google.com/forms/d/e/1FAIpQLSciKlGK_M7Gm0Y1nPyfEVHQpKd8Hc56ASTbzcAd9zgfDO5xlQ/viewform'
            });
        }
        return {
            render: ngLinks
        };
    });   
   


Simple List— A standard list of user-defined column headers and rows.
Example: This script can be used to create form using saved search etc.

Simple List Portlet Object Members:
    Portlet.addColumn(options): Adds a column to the portlet.
    Portlet.addEditColumn(options) : Adds an Edit or Edit/View column to the portlet.
    Portlet.addRow(options) : Adds a row to the portlet.
    Portlet.addRows(options) : Adds multiple rows to the portlet.


/**
 *@NApiVersion 2.x
 *@NScriptType Portlet
 */
define(['N/search'],
    function(search) {
        function render(params) {
            var portlet = params.portlet;
            portlet.title = "NG List";
            portlet.addColumn({
                id: 'custpage_id',
                type: 'text',
                label: 'ID',
                align: 'LEFT'
            });
            portlet.addColumn({
                id: 'custpage_phone',
                type: 'text',
                label: 'Phone',
                align: 'LEFT'
            });
           
           
            var filter = search.createFilter({
                name: 'phone',
                operator: search.Operator.ISNOTEMPTY
            });
            var customerSearch = search.create({
                type: 'customer',
                filters: filter,
                columns: ['internalid', 'phoneno']
            });
            var count = 0;
            customerSearch.run().each(function(result) {
                portlet.addRow(result.getAllValues());
                count = count + 1;
                if(count < 50)
                {
                    return;
                }
               
            });
        }
        return {
            render: render
        };
    });
   
If you have any query, question or suggestion , please comment below or use any of our medium to contact
us. Share with your friend .
 

Download Netsuite Guru Android App
Follow Me on Linkedin
Our FB Page


Thanks
Netsuite Guru

Comments

  1. List Portlet Code is not working..

    A User Error Has Occurred
    {"type":"error.SuiteScriptError","name":"SSS_INVALID_SRCH_COL","message":"An nlobjSearchColumn contains an invalid column, or is not in proper syntax: phoneno.","stack":["each(N/searchObject)","render(/SuiteScripts/sales_performance_summary_2.0.js:34)"],"cause":{"type":"internal error","code":"SSS_INVALID_SRCH_COL","details":"An nlobjSearchColumn contains an invalid column, or is not in proper syntax: phoneno.","userEvent":null,"stackTrace":["each(N/searchObject)","render(/SuiteScripts/sales_performance_summary_2.0.js:34)"],"notifyOff":false},"id":"","notifyOff":false,"userFacing":false}

    ReplyDelete
    Replies
    1. Hi Anaya,
      issue is related to phoneno column, try phone and see if it works.
      Thanks
      Netsuite Guru

      Delete

Post a Comment

Thanks for you message, please join us on Facebook and Linkedin