Friday, October 12, 2018

Make Dashboard Link Available in Suitelet

When viewing an entity list by going to List > Relationship and then choose any of the entity types (Customers, Prospects, Leads, etc.), there is a View Dashboard icon on each record on the list. When this icon is clicked, it will go to the Dashboard page for that particular record showing their information, transactions and KPIs.

To create this icon in a custom search in a Suitelet, use this sample process as guide:
 
1. Create a new Transaction Body Field. Navigate to Customization >  Lists, Records, & Fields > Transaction Body Fields > New.
2. Enter the following:
a. Label = Dashboard Image
b. ID=_dashboard_image
c. Type = Free-Form Text
d. Store Value=F

3. Go to Validation & Defaulting Subtab. Enter the following:
a. Default Value = '<img src="/images/nav/ns_x.gif" height="13" width="16" border="0" title="View Dashboard" class="i_dashboard_gray">'
b. Formula = T
4. Click on Save.

5. Create javascript with name "SuiteletDashboard.js" and upload on the scripts file cabinet:


 function demoList(request, response){

     var list = nlapiCreateList('Simple List');
     list.setStyle(request.getParameter('style'));
     var column = list.addColumn('custbody_dashboard_image', 'text', 'Dashboard', 'left');
     column.setURL("https://system.netsuite.com/app/center/card.nl?sc=-69");
     column.addParamToURL('entityid','entity', true);
     list.addColumn('trandate', 'date', 'Date', 'left');
     list.addColumn('name_display', 'text', 'Customer', 'left');
     list.addColumn('salesrep_display', 'text', 'Sales Rep', 'left');
     list.addColumn('amount', 'currency', 'Amount', 'right');
 
     var returncols = new Array();
     returncols[0] = new nlobjSearchColumn('trandate');
     returncols[1] = new nlobjSearchColumn('entity');
     returncols[2] = new nlobjSearchColumn('name');
     returncols[3] = new nlobjSearchColumn('salesrep');
     returncols[4] = new nlobjSearchColumn('amount');
     returncols[5] = new nlobjSearchColumn('custbody_dashboard_image'); // Dashboard Link
     var results = nlapiSearchRecord('estimate', null, new nlobjSearchFilter('mainline',null,'is','T'), returncols);
     list.addRows( results );
 
     response.writePage( list );
}

6. Create Suitelet. Navigate to Customization > Scripting > Scripts > New. Select SuiteletDashboard.js for the Script File

7. Click on Create Script Record button

8. Select Suitelet

9. Save 
10. Deploy Script and Test.





No comments:

Post a Comment