I have a script: var filters = new Array(); ...
# suitescript
m
I have a script: var filters = new Array(); filters[0] = new nlobjSearchFilter('customrecord_cseg3', null, 'anyof', nlapiGetRecordId()); var columns = new Array(); columns[0] = new nlobjSearchColumn('name'); columns[1] = new nlobjSearchColumn('custrecord1403'); columns[2] = new nlobjSearchColumn('custrecord1408'); var result = nlapiSearchRecord('customrecord_cseg4', null, filters, columns); var customRecords = { columns: columns, results: result }; But when it runs I get this reply: nlobjSearchFilter contains invalid search criteria: customrecord_cseg3. I do not see why this is invalid. Any suggestion as to how to correct this are welcome.
p
Is it in a UE beforesubmit(), or a client script onsave, either for a new transaction? Won’t NlapiGetRecordId() will be undefined in such cases ?
m
It is a User Event before sumbit.
p
That’s your answer then. A new record won’t have an ID, so your filter ends up being incorrect
💯 1
s
If this is a new script, please do not write it in 1.0. It's knowingly adding technical debt immediately.
👍 2
n
+1 @tuli that's the way to do it.
keanu thanks 1
@Max S. use after submit. As @PNJ mentioned there is no record ID (in create mode) in before submit. Also, avoid 1.0 now and use the latest 2.x