Aeol Cross
Aeol Cross

Reputation: 5

Converting SuiteScript 2.0 to 1.0

I was tasked to create a custom search that displays results from the tax code records. I managed to create one but now I have to convert it into SuiteScript 1.0 and I am still not familiar with it. Where should I start first? Here is my code:

define(['N/log', 'N/ui/serverWidget', 'N/record', 'N/search'], function(log, serverWidget, record, search) {

    function onRequest(context) {

        var objClass = {};

        if (context.request.method === 'GET') {

            var list = serverWidget.createList({
                title : 'Custom Tax Search'
            });
            list.addColumn({
                id : 'internalid',
                type : serverWidget.FieldType.TEXT,
                label : 'Internal ID',
                align : serverWidget.LayoutJustification.LEFT
            });
            list.addColumn({
                id : 'itemid',
                type : serverWidget.FieldType.TEXT,
                label : 'Item ID',
                align : serverWidget.LayoutJustification.LEFT
            });

            list.addColumn({
                id : 'rate',
                type : serverWidget.FieldType.TEXT,
                label : 'Rate',
                align : serverWidget.LayoutJustification.LEFT
            });

            list.addColumn({
                id : 'taxtype',
                type : serverWidget.FieldType.TEXT,
                label : 'Tax Type',
                align : serverWidget.LayoutJustification.LEFT
            });



            var results  = [];

            //Create Search
            var objColumns = [{
                name: 'internalid'
            }, {
                name: 'itemid'
            }, {
                name: 'rate'
            }, {
                name: 'taxtype'
            }];

            var searchObj = search.create({
                type: search.Type.SALES_TAX_ITEM,
                columns: objColumns,
            });

            searchObj.run().each(function(result) {
                var res = {};
                res['internalid'] = result.getValue({
                    name: 'internalid'
                });
                res['itemid'] = result.getValue({
                    name: 'itemid'
                });

                res['rate'] = result.getValue({
                    name: 'rate'
                });

                res['taxtype'] = result.getText({
                    name: 'taxtype'
                });

                results.push(res);
                return true;
            });

            log.debug('results',results);
            list.addRows({
                rows : results
            });

            context.response.writePage(list);

        }
    }

    return {
        onRequest: onRequest
    };
}); 

Upvotes: 0

Views: 1123

Answers (1)

Avi
Avi

Reputation: 2069

NetSuite has a complete list of functions from SuiteScript 1.0 to 2.0 migration, you can refer that and work your around it.

nlapi: SuiteScript 1.0 to SuiteScript 2.0 API Map

nlobj: SuiteScript 1.0 to SuiteScript 2.0 API Map

Upvotes: 2

Related Questions