I’m wondering if anyone can help me figure out thi...
# suitescript
j
I’m wondering if anyone can help me figure out this issue… I am running a search on “vendor” like so:
Copy code
function modifiedDateSearch(){
    const results = []
    var mySearch = search.create({
        "type": "vendor",
        "filters": [
            ['lastmodifieddate', search.Operator.WITHIN, '20DaysAgo']
        ],
        "columns": entityColumns,
    })
    mySearch.run()
        .getRange({
            start: 0,
            end: 1000
        })
        .forEach(function(result)
            {
                results.push(JSON.stringify(result));
            }
        )
    return results
}
where
entityColumns
is an array containing each of the Internal IDs listed in the “Search Columns” table of this document” http://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2018_1/script/record/vendor.html .
When I try to run this, I am seeing errors like
{"type":"error.SuiteScriptError","name":"SSS_INVALID_SRCH_COL","message":"An nlobjSearchColumn contains an invalid column, or is not in proper syntax: language."}
for several columns. Why can I not include these columns, and is there a way for me to get them if I need them?
Copy code
const entityColumns = [
   'accountnumber',
   'address',
   'addressee',
   'addressinternalid',
   'addresslabel',
   'addressphone',
   'altcontact',
   'altemail',
   'altname',
   'altphone',
   'attention',
   'balance',
   'billcountrycode',
   'billzipcode',
   'category',
   'city',
   'comments',
   'companyname',
   'contact',
   'country',
   'countrycode',
   'creditlimit',
   'currency',
   'currentexchangerate',
   'datecreated',
   'eligibleforcommission',
   'email',
   'emailpreference',
   'emailtransactions',
   'entityid',
   'entitynumber',
   'expenseaccount',
   'externalid',
   'fax',
   'faxtransactions',
   'firstname',
   'formulacurrency',
   'formuladate',
   'formuladatetime',
   'formulanumeric',
   'formulapercent',
   'formulatext',
   'fxbalance',
   'fxunbilledorders',
   'giveaccess',
   'globalsubscriptionstatus',
   'hasduplicates',
   'homephone',
   'image',
   'incoterm',
   'internalid',
   'is1099eligible',
   'isdefaultbilling',
   'isdefaultshipping',
   'isinactive',
   'isjobresourcevend',
   'isperson',
   'laborcost',
   'language',
   'lastmodifieddate',
   'lastname',
   'lastviewed',
   'level',
   'middlename',
   'mobilephone',
   'payablesaccount',
   'pec',
   'permission',
   'phone',
   'phoneticname',
   'printoncheckas',
   'printtransactions',
   'purchaseorderamount',
   'purchaseorderquantity',
   'purchaseorderquantitydiff',
   'receiptamount',
   'receiptquantity',
   'receiptquantitydiff',
   'representingsubsidiary',
   'salutation',
   'shipcountrycode',
   'state',
   'statedisplayname',
   'subscription',
   'subscriptiondate',
   'subscriptionstatus',
   'subsidiary',
   'subsidiarynohierarchy',
   'taxidnum',
   'terms',
   'title',
   'type',
   'unbilledorders',
   'url',
   'vatregnumber',
   'workcalendar',
   'zipcode',
]
r
Based on the error, language is not a valid search column. Have you verified if you can add language as a search column in the UI?
j
No, let me try that
The
columns
parameter should correspond to a field on each of the objects in the result set, right?
s
no, technically you have to call
getValue
on each result field
j
That results in the same error
s
well the error you're talking about would happen *prior * to getting search results to enumerate over 🙂
j
you’re right lol
s
I'd recommend leaving out the field names producing those errors - the NS records browser documentation is infamously imperfect
j
hm
s
if it's only a few, just pretend they are typos in the record browser docs, as there's not much else you can do AFAIK
j
well at least I’ve discovered that I can load these modules in the developer console to debug
s
if you want search result [columns] to surface as 'normal JS properties" I'd recommend NFT
j
NFT?
This seems to work fine
Copy code
mySearch.run()
        .getRange({
            start: 0,
            end: 1000
        })
        .forEach(function(result)
            {
                results.push(JSON.stringify(result));
            }
        )
    return results
oh just saw your edit
s
I'm saying
JSON.stringify()
and using the output is asking for trouble, as there is no documented structure for the output of that call, and hence NS can change it at any time.
recurring problems pop up on this slack about people who are relying on the output of JSON.stringify(<insert some NS type here>)
in other words,
result
is your only reliable (documented) object to use above, not the string output of
JSON.stringify()
)
j
gotcha
401 Views