I have the following SuiteScript 2.0 code in a Suitelet where I would like to add an additional filter to the loaded saved search (inventory items sublist and main record of the Inventory Adjustment record):
var rs = s.load({
id: "customsearch_inv_adj_item_search"
});
// Copy the filters from rs into defaultFilters.
var defaultFilters = rs.filters;
var customFilters = [
s.createFilter({
name: "internalid",
operator: s.Operator.IS,
values: request.parameters.custscript_report_context.toString()
}),
];
// Push the customFilters into defaultFilters.
defaultFilters.push(customFilters);
// Copy the modified defaultFilters back into rs
rs.filters = defaultFilters;
var results = rs.run().getRange(0, 1000);
However the code keeps on failing on the line rs.filters = defaultFilters;
with the error:
{"type":"error.SuiteScriptError","name":"WRONG_PARAMETER_TYPE","message":"Wrong parameter type: filters[2] is expected as Filter. ","stack":["createError(N/error)","onRequest(/SuiteScripts/sui_custom_pdf_report.js:308)","createError(N/error)"],"cause":{"name":"WRONG_PARAMETER_TYPE","message":"Wrong parameter type: filters[2] is expected as Filter. "},"id":"","notifyOff":false,"userFacing":true}
Instead of request.parameters.custscript_report_context.toString()
I have tried 981, "981", ["981"]
but no luck.
custscript_report_context
is of type integer and it works fine in trying to load the record via N\record
.
I am returning internalid
in my saved search as a column.
Does anyone know what I'm doing wrong?