Hi Guys, I am passing filters in existing Saved Se...
# suitescript
a
Hi Guys, I am passing filters in existing Saved Searches but not able to add, getting error "Wrong parameter type: filters is expected as Array. "... this Saved Searches is actually to check the last run time of the script. var searchObj = search.load({ id: searchId }); if (isNotNull(lastRunDate) && isNotNull(searchId) && isNotNull(aFile)) { var filters = searchObj.filters; var columns = searchObj.columns; filters.push(["datecreated", "onorafter", toNSSearchableDatetime(lastRunDate)]) filters.push("OR"); filters.push(["lastmodifieddate", "onorafter", toNSSearchableDatetime(lastRunDate)]) // Create search task var searchTask = search.create({ taskType: task.TaskType.TRANSACTION, title: 'Saved Search_123', filters: [filters], columns: columns }); var searchTaskId = searchTask.save(); // Create search task var searchTask = task.create({ taskType: task.TaskType.SEARCH }); searchTask.savedSearchId = searchTaskId; searchTask.fileId = aFile; var searchTaskId = searchTask.submit(); var summary = task.checkStatus(searchTaskId); log.audit({ title: 'Status', details: summary.status }); } Any help on this?
s
You need to use search.createFilter to add them; you cannot use the shorthand array syntax when trying to add them to a loaded search.
b
before you go further, you need to know the difference between a filterExpression and filters
you will need to know the distinction enough to know when you should use one over the other