Tiina Böös
09/10/2025, 1:50 PMCeligo AI
09/10/2025, 1:50 PMAI generated answer (using internal Slack threads):To send an email if a Scheduled script fails in NetSuite, you can use the
try-catch
block in your script. In the catch
block, you can use the email.send()
API to send an email when an error occurs.
Here is a sample code snippet:
javascript
try {
// Your scheduled script code here
} catch (e) {
var author = -5; // -5 is the internal ID of the system user
var recipients = '<mailto:example@example.com|example@example.com>'; // replace with your email
var subject = 'Scheduled Script Failed';
var body = 'Error Details: ' + e.message;
email.send({
author: author,
recipients: recipients,
subject: subject,
body: body
});
}
In this code, the try
block contains your scheduled script code. If any error occurs while executing this code, the control will move to the catch
block. In the catch
block, an email is sent with the error details.
Please note that the author
is set to -5
, which is the internal ID of the system user. This is because the current user in a scheduled script is "System", which is not an employee and trying to send an email as "System" will cause an Unexpected Error. It's a good practice to have a dummy "No Reply" employee record (doesn't need NetSuite access, just an email) and set it as a script preference.
******
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
09/10/2025, 1:50 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.844116271
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.841735959
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.835693419
Celigo AI
09/10/2025, 1:50 PM