David Captur
08/28/2024, 9:42 AMCeligo AI
08/28/2024, 9:42 AMAI generated answer (using internal Slack threads):Here is a step-by-step guide on how to create a SuiteScript that runs a Saved Search and sends an email if the record count is larger than 500: 1. Create a Scheduled Script: Go to Customization > Scripting > Scripts > New. Select 'Scheduled Script' as the script type. Upload your .js file and give your script a name and ID. 2. Write the SuiteScript: In your .js file, you will need to use the
nlapiSearchRecord
function to run the Saved Search, and the nlapiSendEmail
function to send the email. Here is a sample script:
javascript
function scheduled(type) {
var search = nlapiLoadSearch(null, 'customsearch1882');
var resultSet = search.runSearch();
var results = resultSet.getResults(0, 1000);
if (results.length > 500) {
var emailSubject = 'High Amount of NetSuite Production SOAP WS Calls Last Night';
var emailBody = 'Last night over 500 Netsuite SOAP WS calls were made on Production';
var recipients = ['<mailto:flip@flop.com|flip@flop.com>', '<mailto:tip@top.com|tip@top.com>'];
nlapiSendEmail(-5, recipients, emailSubject, emailBody);
}
}
3. Set the Script Deployment: After creating the script record, you will be redirected to the script deployment page. Set the status to 'Scheduled', and set the 'Start Time' to 5am. Make sure the 'Recurrence' is set to 'Daily'.
4. Save and Test: Save the script deployment and test it to make sure it works as expected.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
08/28/2024, 9:43 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.858428359
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.851278365
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.848180652
Celigo AI
08/28/2024, 9:43 AMCeligo AI
08/28/2024, 10:07 AM