Reputation: 1007
I have a Saved Search (SS) which yields results when run in the browser. However, when executed in code, via a Scheduled Script, there are no results.
Here's a simplified example:
The SS with ID customsearch1181 returns 10 results in the browser.
However, after executing the script below, the results array is empty.
We can assume the SS will yield less than 4k results so there's no need to run a paged search.
define(['N/search'],
(search) => {
const execute = (scriptContext) => {
const custSearch = search.load({id: 'customsearch1181'});
const results = [];
custSearch.run().each( function(result) {
results.push(result);
return true;
});
log.debug({title: 'search result count', details: results.length});
}
return {execute}
});
This script does log results for other SS IDs. One observation I've made is that there are a lot of filters on the SS under question.
Has anyone experienced this issue? What is responsible for this behavior?
Upvotes: 1
Views: 614
Reputation: 88
Here SS is a server-side script executed as admin as user "system".
Here user-specific filters/ permissions may affect the filters.
Please test with manual trigger (Save & execute) & scheduled triggers separately.
Hope this assumption will help to find what is the issue
Upvotes: 1