David Captur
08/28/2024, 2:04 PMCeligo AI
08/28/2024, 2:04 PMAI 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 new SuiteScript of type 'Scheduled Script'. You can do this by navigating to
Customization > Scripting > Scripts > New
, and then selecting 'Scheduled Script' from the list.
2. In the script file, you will need to use the N/search
module to load and run your Saved Search. Here is a sample code snippet:
javascript
var search = require('N/search');
function execute(context) {
var mySearch = search.load({
id: 'customsearch1882'
});
var resultSet = mySearch.run();
var results = resultSet.getRange({
start: 0,
end: 1000
});
if (results.length > 500) {
sendEmail();
}
}
3. In the sendEmail
function, use the N/email
module to send an email. Here is a sample code snippet:
javascript
var email = require('N/email');
function sendEmail() {
email.send({
author: -5, // -5 is the internal ID for the system user
recipients: ['<mailto:flip@flop.com|flip@flop.com>', '<mailto:tip@top.com|tip@top.com>'],
subject: 'High Amount of NetSuite Production SOAP WS Calls Last Night',
body: 'Last night over 500 Netsuite SOAP WS calls were made on Production'
});
}
4. Deploy the script and set the schedule. You can do this by navigating to Customization > Scripting > Script Deployments > New
. Set the 'Start Time' to 5am and the 'Interval' to 'Daily'.
Please note that the above code snippets are just examples and may need to be adjusted to fit your specific needs.
******
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, 2:05 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.852972448
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.85217452
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.847050726
Celigo AI
08/28/2024, 2:05 PM