Rick Goodrow
07/17/2024, 4:21 PMlet accountingPeriodSearch = Nsearch.load({
id: uvLibID.savedSearch.ACCOUNTING_PERIOD,
});
let searchStartDate = Nformat.format({
type: Nformat.Type.DATE,
value: startDate.toDate(),
});
let searchEndDate = Nformat.format({
type: Nformat.Type.DATE,
value: endDate.toDate(),
});
accountingPeriodSearch.filters.push(Nsearch.createFilter({
name: uvLibID.field.ACCOUNTING_PERIOD.START_DATE,
operator: Nsearch.Operator.ON,
values: searchStartDate,
}));
accountingPeriodSearch.filters.push(Nsearch.createFilter({
name: uvLibID.field.ACCOUNTING_PERIOD.END_DATE,
operator: Nsearch.Operator.ON,
values: searchEndDate,
}));
accountingPeriodSearch.run();
works fine, but if I try to use filter expressions with the same params instead
let accountingPeriodSearch = Nsearch.load({
id: uvLibID.savedSearch.ACCOUNTING_PERIOD,
});
let searchStartDate = Nformat.format({
type: Nformat.Type.DATE,
value: startDate.toDate(),
});
let searchEndDate = Nformat.format({
type: Nformat.Type.DATE,
value: endDate.toDate(),
});
accountingPeriodSearch.filterExpression = [
[ uvLibID.field.ACCOUNTING_PERIOD.START_DATE, Nsearch.Operator.ON, searchStartDate ],
[ 'AND' ], // Tried with & without, no difference
[ uvLibID.field.ACCOUNTING_PERIOD.END_DATE, Nsearch.Operator.ON, searchEndDate ],
];
accountingPeriodSearch.run();
NetSuite throws a
{"type":"error.SuiteScriptError","name":"SSS_INVALID_SRCH_FILTER_EXPR","message":"Malformed search filter expression.","id":"",...}
jen
07/17/2024, 4:33 PMjen
07/17/2024, 4:34 PMRick Goodrow
07/17/2024, 4:35 PMjen
07/17/2024, 4:35 PMRick Goodrow
07/17/2024, 4:43 PMjen
07/17/2024, 5:00 PM