Display of "is not a valid internal id" in Netsuite Suitescript 1.0 when creating a Search on a particular record

1.2k views Asked by At

I have created a search in Netsuite using Suitescript 1.0 for searching a particular "Account" using its account number. When I save the following script file, an error is being displayed in "filters[0]" line in the code below, where it says "acctnumber is not a valid internal id.". I am new to Netsuite and would want to know why the error is being displayed, and the solution for the same. Below is the following piece of code written in which the error is being occured.

function COGSAcnt() {
    var cOGSAcntNumber = '50001';

    var acntNo;
    var filters = new Array();
    filters[0] = new nlobjSearchFilter('acctnumber', null, 'startswith', cOGSAcntNumber);

    var columns = new Array();
    columns[0] = new nlobjSearchColumn('internalid');

    var acntSearch = nlapiSearchRecord('account', null, filters, columns);
    if (acntSearch != null) {
    for (x=0; x<acntSearch.length; x++) {
        acntNo = ITMSearch[x].getValue('internalid');
    }
    }
    nlapiLogExecution('debug', 'acntNo', acntNo);
    return acntNo;
}

NOTE: I want the filter to be acctnumber (Account Number), and using that would want to retrieve the internalid of the account in Netsuite.

2

There are 2 answers

0
TMann On BEST ANSWER

This is where NS can be a little confusing. If you look at the NS Record browser (http://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2016_2/script/record/account.html) look under the Filters section. Account Number (acctnumber) isn't there. However Number (number) is the filter.

Try rewriting the code to use number instead

0
UDAY On
function COGSAcnt() {
var cOGSAcntNumber = '50001';

var acntNo = [];
var filters = new nlobjSearchFilter('number', null, 'startswith', cOGSAcntNumber);

var acntSearch = nlapiSearchRecord('account', null, filters, columns);
if (acntSearch != null) {
for (x=0; x<acntSearch.length; x++) {
    acntNo.push(ITMSearch[x].getId();
}
}

return acntNo;
}