Hi,I'm doing a search query that throws an unexpected error.
Here is the error log:
{"type":"error.SuiteScriptError","name":"UNEXPECTED_ERROR","message":null,"stack":["getRange(N/searchObject)","searchAll(/SuiteScripts/AECC_SL_InboundShipment.js:991)","getData(/SuiteScripts/AECC_SL_InboundShipment.js:620)","handleGet(/SuiteScripts/AECC_SL_InboundShipment.js:349)","inboundShipment(/SuiteScripts/AECC_SL_InboundShipment.js:36)"],"cause":{"type":"internal error","code":"UNEXPECTED_ERROR","details":null,"userEvent":null,"stackTrace":["getRange(N/searchObject)","searchAll(/SuiteScripts/AECC_SL_InboundShipment.js:991)","getData(/SuiteScripts/AECC_SL_InboundShipment.js:620)","handleGet(/SuiteScripts/AECC_SL_InboundShipment.js:349)","inboundShipment(/SuiteScripts/AECC_SL_InboundShipment.js:36)"],"notifyOff":false},"id":"eb3b4892-5be4-40e1-9d0f-784954b577b9-2d323032312e30332e3236","notifyOff":false,"userFacing":false}
I was able to narrow it down to the last filter (batch number). I tried using Operator.ANYOF, Operator.IS and Operator.CONTAINS and in all cases it fails with this unexpected error. Also, I validated the the custom column I'm trying to filter on exist (if I put a column name that doesn't exist I do get a proper error that the column doesn't exist):
prbmevar po_search_filters = [];
po_search_filters.push(search.createFilter({
name: 'mainline',
operator: search.Operator.IS,
values: false
}));
po_search_filters.push(search.createFilter({
name: 'status',
operator: search.Operator.ANYOF,
values: ['PurchOrd:B','PurchOrd:E','PurchOrd:D']
}));
po_search_filters.push(search.createFilter({
name: 'custitemnumber_aecc_is_ibs_created',
join: 'itemnumber',
operator: search.Operator.IS,
values: false
}));
po_search_filters.push(search.createFilter({
name: 'custitemnumber_aecc_is_received_flag',
join: 'itemnumber',
operator: search.Operator.IS,
values: false
}));
po_search_filters.push(search.createFilter({
name: 'inventorynumber',
join: 'itemnumber',
operator: search.Operator.ISNOTEMPTY,
values: ''
}));
/* This is the problematic filter */
po_search_filters.push(search.createFilter({
name: 'custitemnumber_aecc_batch_no',
join: 'itemnumber',
operator: search.Operator.CONTAINS,
values: 'some-batch-no'
}));
var po_search = search.create({
type: 'purchaseorder',
filters: po_search_filters,
columns: [ <list of columns> ]
});