How to create a simple RestLet in NetSuite

function getData(params){ 
    var arr =[];
    
    var columns = [];  

    columns.push(new nlobjSearchColumn('internalid',null,'group')); // nsid  0 
    columns.push(new nlobjSearchColumn('itemid', null, 'group')); //  name 1
    
    var filters=[];
    
    
    if(!params.recordPosBegin){
        params.recordPosBegin=0;
    }
    if(!params.recordPosEnd){
        params.recordPosEnd=1000;
    }

    var search = nlapiCreateSearch('item',filters,columns);
    var resultSet = search.runSearch();
    

    
    var VariantArray =[];
    
        
    var results = resultSet.getResults(params.recordPosBegin,params.recordPosEnd);  
    if (results != null) {
        nlapiLogExecution("DEBUG", "SEARCH Size",results.length );
        for (var i = 0; i < results.length; i += 1) {
                        
            var data ={
                      "nsid": results[i].getValue(columns[0]),
                      "itemID": results[i].getValue(columns[1]),                                     
                     }; 
            
            arr.push(data);     
        
            
        }

    }
    return {products:arr};
}

Creating a simple RestLet In JavaScript

 The above RestLet is the simple restlet example in NetSuite.

Popular posts from this blog

What are sales territory in Netsuite?

How to get and set a sublist in netsuite suitlet suitescript 2.0