How to get category, price and inventory in Netsuite SuiteScript

 function GetCategory(id){
    var CategoryArray = [];
    
    // Loop to Site Category
    var record = nlapiLoadRecord('inventoryitem', id);
    var categoryCount = record.getLineItemCount('sitecategory');        
    
    if(categoryCount > 0)
    {
        for(var i=1 ;i<=categoryCount ; i++)
        {
            var category = {
                "category" : record.getLineItemText('sitecategory', 'category', i)
                  };
            CategoryArray.push(category);
        }
    }
  return CategoryArray;
}
The above function will fetch the total category and return the results in the form of array


And to get Online price  and Inventory use DECODE function with formulae

 
  
    //Online price 3
    columns.push(new nlobjSearchColumn('formulacurrency',null,'max').setFormula( 
     "DECODE({pricing.pricelevel},'Online Price',DECODE({pricing.currency},'USD',
     {pricing.unitprice}))"));
 
    columns.push(new nlobjSearchColumn('formulanumeric',null,'max').setFormula(
    "DECODE({inventorylocation},'Main Warehouse',{locationquantityavailable})"));  
    // inventory 4       
 

Comments

Popular posts from this blog

What are sales territory in Netsuite?

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