Skip to main content
1-Visitor
October 11, 2016
Solved

How do I make a script run as a rule if it is currently configured to be scheduled?

  • October 11, 2016
  • 1 reply
  • 1472 views

I have a scheduled script, and I've modified it to have an additional functionality to run as a rule. However, when I did run my rule trigger I received an error that the script may be run only from a scheduled trigger. I looked in the script and I couldn't find any sort of tag or check which specifically labels it as a scheduled trigger. How do I prevent this error and allow my script to run as a rule?

This is a similar scenario to the other question here.

Error while execution of a Rule based trigger

Thanks

    Best answer by bcollins-2

    Actually I found the line that was causing this. That's embarrassing, but I'll leave this here in case anyone else gets stuck on it. The line below ensures that a script will only run in a scheduled context.

    if (eb.getEventContext() != "Schedule")

        eb.badConfiguration(rb.handleGetObject("ONLY_SCHEDULED_TRIGGER"));

    1 reply

    bcollins-21-VisitorAuthorAnswer
    1-Visitor
    October 11, 2016

    Actually I found the line that was causing this. That's embarrassing, but I'll leave this here in case anyone else gets stuck on it. The line below ensures that a script will only run in a scheduled context.

    if (eb.getEventContext() != "Schedule")

        eb.badConfiguration(rb.handleGetObject("ONLY_SCHEDULED_TRIGGER"));