Can you run a scheduled script on demand
# ask-stanley-ai
r
Can you run a scheduled script on demand
c
AI generated answer (using internal Slack threads):
Yes, you can run a scheduled script on demand in NetSuite. This can be done by using the 'Save and Execute' button on the script deployment page. However, please note that if there are other scripts currently running in the queue, your script will not interrupt them and will have to wait its turn. If you are using SuiteCloud Plus, you can reserve a processor for high priority jobs and run your scheduled script with high priority. This can help in ensuring that your script runs as soon as possible. If you want your script to run only during certain hours, you would need to write code into the script itself to check the current time and decide whether to execute or not. For example, the script could start per NetSuite deployment schedule, but then return if the current time is after a certain hour. Here is an example of a scheduled script that can be run on demand:
Copy code
javascript
/**
 *@NApiVersion 2.1
 *@NScriptType ScheduledScript
 */

import { EntryPoints } from "N/types";
import log from "N/log";

async function execute(context: EntryPoints.Scheduled.executeContext) {
  if (context.type !== context.InvocationType.ON_DEMAND) return;
  try {
    log.debug("Hello World", "I'm an on demand scheduled script");
  } catch (e) {
    log.error("Error", e);
  }
  return "Hello World";
}

export = {
  execute,
};
****** 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.862183809
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.849580944
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.84724474
Please provide your feedback on this answer.