How to create a simple search in Netsuite Suitlet

function searchCompanyID(companyname){
    
         var filters = new Array();
         filters[0] = new nlobjSearchFilter ('companyname', null, 'is', companyname);
        
         var columns = new Array();
         columns[0] = new nlobjSearchColumn('internalid');   
         
         var searchResults = nlapiSearchRecord('customer', null, filters, columns);
         
         if (searchResults != null) {
             var internalid = searchResults[0].getValue(columns[0]);
             return internalid;
         }
         else{
             return 0;
         }
    
}

Popular posts from this blog

What are sales territory in Netsuite?

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