This topic contains 3 replies, has 0 voices, and was last updated by Vinayak 7 years, 4 months ago.

  • Author
    Posts
  • #21738 Score: 0

    Vinayak
    • Contributions: 0
    • Level 1

    Hello everyone,

    Is there any way to show huge bulk of data on suitelet using sublist (on or table )also along with data there will be other fields to filter those results and also one button to process that list results. I am facing performance issues. Please advice if I can achieve this using HTML or some other method like pagination or any other best method.

    Thanks
    This is a cached copy. Click here to see the original post.

  • #21739 Score: 0

    Olivier Gagnon NC
    • Contributions: 0
    • Level 1

    Yes I have done this in the past. You can manage your own mechanism using an HTML construct (instead of NS sublist) and then maybe something like a JSON cache to manage pagination. Worked well when I did it.

  • #21740 Score: 0

    michoel
    • Contributions: 0
    • Level 1

    Here is an example of doing something like this with DataTables for pagination

    mos_product_search.js

    Code:
    /**
    * Suitelet to make searching for stock codes really easy
    *
    * Script Type: Suitelet
    *
    */

    function getItems() {

    var columns = ['internalid', 'itemid', 'salesdescription', 'baseprice', 'lastpurchaseprice', 'custitem_uom', 'upccode', 'quantityonhand', 'vendorcode'];

    var searchcolumns = [];
    for(var col in columns) {
    searchcolumns.push(new nlobjSearchColumn(columns[col]));
    }

    var search = nlapiCreateSearch('item', null, searchcolumns);
    var results = search.runSearch();
    var items = [], slice = [], i = 0;
    do {
    slice = results.getResults(i, i + 1000);
    for (var itm in slice) {
    var item = {};
    for(col in columns) { item[columns[col]] = slice[itm].getValue(columns[col]); } // convert nlobjSearchResult into simple js object
    items.push(item);
    i++;
    }
    } while (slice.length >= 1000);

    return items;
    }

    function suitelet (request, response) {

    switch(request.getParameter('custom_request_type')) {

    case 'items':

    var items = JSON.stringify(getItems());
    response.write(items);
    break;

    case 'html':

    var content = nlapiLoadFile('SuiteScripts/MOS Customizations/productsearch/mos_product_search.html').getValue();
    response.write(content);
    break;

    default:

    var url = nlapiResolveURL('SUITELET', 'customscript_mos_stock_code_search', 'customdeploy_mos_stock_code_search');
    var form = nlapiCreateForm('Product Search');
    form.addField('content', 'inlinehtml', '')
    .setDefaultValue('<iframe style="display: block; height: 80vh; width: 100%; border: none;" src="' + url + '&custom_request_type=html"></iframe>');
    response.writePage(form);
    }
    }
    mos_product_search.html

    HTML Code:
    <!DOCTYPE html>
    <html lang="en">

    <head>
    <meta charset="utf-8">

    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/r/zf-5.5.2/jq-2.1.4,dt-1.10.9/datatables.min.css"/&gt;
    <script type="text/javascript" src="https://cdn.datatables.net/r/zf-5.5.2/jq-2.1.4,dt-1.10.9/datatables.min.js"></script&gt;

    <script>
    "use strict";

    $(document).ready(function(){

    $.fn.dataTable.ext.errMode = 'none';

    var table = $('#table_search')
    .on('error.dt', function (e, settings, techNote, message) {
    console.log( 'An error has been reported by DataTables: ', message );
    })
    .DataTable({
    ajax: function (data, callback, settings) {
    var data = localStorage.getItem('product_data');
    callback({ 'data': JSON.parse(data) || [] });
    },
    columns: [
    { title: "Code", data: 'itemid', width: "20%", render: function(data, type, row, meta) {return '<a href="/app/common/item/item.nl?id=' + row.internalid + '" target="_blank">' + data + '</a>';} },
    { title: "Description", data: 'salesdescription', width: "45%" },
    { title: "Supplier Code", data: 'vendorcode', width: "10%" },
    { title: "Barcode", data: 'upccode', width: "5%" },
    { title: "UOM", data: 'custitem_uom', width: "5%" },
    { title: "QOH", data: 'quantityonhand', width: "5%" },
    { title: "Last Cost", data: 'lastpurchaseprice', width: "5%" },
    { title: "Sell Price", data: 'baseprice', width: "5%" }
    ]
    });

    var url = window.location.href;
    url = url.replace('custom_request_type=html', 'custom_request_type=items');

    var updateData = function() {
    $.get(url, function(data) {
    localStorage.setItem('product_data', data);
    table.ajax.reload(null, false);
    });
    }();

    window.setInterval(updateData, 900000);
    });

    </script>

    </head>

    <body>
    <div class="container">
    <table id="table_search" class="display compact" cellspacing="0" width="100%">
    </table>
    </div>
    </body>

    </html>


    david.smith replied on 04/04/2017, 10:32 AM: love datatables! great product.

  • #21741 Score: 0

    Vinayak
    • Contributions: 0
    • Level 1

    michoel

    Hi michoel..

    the code which u have given for bulk data, I tried with the same code but I am not able to fetch data from netsuite and also m not able to show on table… I guess when I run the script then html part ill get triggered but after m not able to call Item get functionality from HTML page… when I run the code it showing me table n loading message inside the table.Please help me to to solve the issue

You must be logged in to reply to this topic.