I've created a NetSuite Saved search that is captu...
# ask-stanley-ai
d
I've created a NetSuite Saved search that is capturing SOAP API Calls that occurred between these periods: Yesterday from 8pm onwards till today at 5am. The report is working well, but what I want to do is schedule the report to only email me IF the total record count exceeds 500. The idea being that at night there should be little activity, so anything higher than 500 API calls would be suspicious and I want to know about it. Unfortunately I cannot find a way to only send the report when the record count higher than 500, I either always send it, or I don't. Is there a way?
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that NetSuite Saved Searches do not have a built-in feature to only send an email when the record count exceeds a certain number. However, you can potentially achieve this by using a combination of SuiteScript and Scheduled Scripts. Here's a high-level approach: 1. Create a SuiteScript that runs your saved search and gets the count of the results. 2. If the count exceeds 500, the script should send an email to you with the results. 3. Schedule this script to run at your desired intervals (e.g., every day at 5am). Here's a pseudo-code example of what the SuiteScript might look like:
Copy code
javascript
var search = nlapiLoadSearch(null, 'customsearch_your_saved_search_id');
var resultSet = search.runSearch();
var count = resultSet.getResults(0, 1000).length; // adjust the range as needed

if (count > 500) {
    // send email
    nlapiSendEmail(
        nlapiGetContext().getUser(), // sender
        '<mailto:your@email.com|your@email.com>', // recipient
        'Saved Search Results', // subject
        'The saved search returned more than 500 results.' // body
    );
}
Please replace
'customsearch_your_saved_search_id'
with the actual ID of your saved search, and
'<mailto:your@email.com|your@email.com>'
with your actual email address. Remember to schedule this script to run at your desired intervals using NetSuite's Scheduled Script feature. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.842216372
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.841913104
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.841866493
Please provide your feedback on this answer.