• Categories
  • Recent
  • Tags
  • Popular
  • Solved
  • Unsolved
  • Users
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Darkly)
  • No Skin
Collapse
brainCloud Forums

ScheduleRunScriptUTCv2 doesn't seem to work as expected?

Scheduled Pinned Locked Moved Solved Cloud Code
7 Posts 2 Posters 95 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    william
    wrote last edited by william
    #1

    In the API docs for ScheduleRunScriptUTCv2, the description for the scriptName parameter says:

    The name of the script with its absolute path to be run.

    https://docs.braincloudservers.com/api/capi/script/schedulerunscriptutcv2

    I've tried auto-rescheduling a script with bridge.getScriptName() given for the scriptName, which seemingly gives the correct full path, but when the scheduled job tries to run, it says it can't find the script:

    Screenshot 2025-09-08 at 10.46.45 AM.png

    Script not found: RefreshWeeklyChallengeCourse

    This is a snippet of the code used to schedule the new run job:

    /**
     * @returns {number} The next run date in UTC millis.
     */
    function setNextScheduledRun() {
      let scriptProxy = bridge.getScriptServiceProxy();
    
      const now = new Date();
    
      const nextRunDate = new Date(Date.UTC(
        now.getUTCFullYear(),
        now.getUTCMonth(),
        now.getUTCDate(),
        2
      ));
    
      setToNextDayOfWeek(nextRunDate, data.dayOfWeek);
    
    
      let scriptData = data;
      let scriptName = String(bridge.getScriptName());
      let nextRunMillis = nextRunDate.getTime();
    
      bridge.logInfo(`Next run: ${nextRunDate.toISOString()}`);
      bridge.logInfo(`Next run millis: ${nextRunMillis}`);
    
      if (!data.dryRun) {
        cancelExcessJobs(scriptProxy, scriptName, nextRunDate);
      }
      
      let scheduleResponse = scriptProxy.scheduleRunScriptUTCv2(scriptName, scriptData, nextRunMillis);
    
      if (scheduleResponse.status !== 200) {
        bridge.logErrorJson("Failed to schedule next script run", scheduleResponse);
        return 0;
      }
    
      return nextRunMillis;
    }
    

    When I've manually ran the script via the API Explorer, everything works correctly and a job is scheduled. Only once I've moved the script to the root folder does it find the script and work. While this gets the job done, the issue feels like either a bug in the API or a documentation issue that could use updating.

    If I'm misunderstanding something, please feel free to correct me, but I wanted to bring it up in the event that it is indeed a bug. Thank you in advance for your time.

    1 Reply Last reply
    0
  • Paul WinterhalderP Offline
    Paul WinterhalderP Offline
    Paul Winterhalder brainCloudAdmin
    wrote last edited by
    #2

    Hi - clever use of getScriptName() - maybe too clever! 🙂

    I'm passing this onto the devs. My guess is that bridge.getScriptName() isn't returning the full [or proper] path to the script.

    We'll check it out and get back to you!

    1 Reply Last reply
    0
  • Paul WinterhalderP Offline
    Paul WinterhalderP Offline
    Paul Winterhalder brainCloudAdmin
    wrote last edited by
    #3

    HI @william ,

    The devs identified an "inconsistency" in the implementation of that bridge call - where, depending upon how a script was invoked, the property being consulted to return the results wasn't always set.

    We're preparing a fix to patch in later today.

    Thanks for reporting this!

    1 Reply Last reply
    0
  • W Offline
    W Offline
    william
    wrote last edited by
    #4

    Any time - thanks for looking into it!

    1 Reply Last reply
    0
  • W william has marked this topic as solved
  • Paul WinterhalderP Offline
    Paul WinterhalderP Offline
    Paul Winterhalder brainCloudAdmin
    wrote last edited by
    #5

    Hi @william,

    We've deployed a patch for this. Can you re-test and let it know if it solved your problem?

    Paul.

    1 Reply Last reply
    0
  • W Offline
    W Offline
    william
    wrote last edited by
    #6

    Hey @Paul-Winterhalder

    Tested and it works like a charm. Thanks again!

    1 Reply Last reply
    0
  • Paul WinterhalderP Offline
    Paul WinterhalderP Offline
    Paul Winterhalder brainCloudAdmin
    wrote last edited by
    #7

    Cool - good to hear it. And once again: thanks for reporting it!

    1 Reply Last reply
    0

  • Login

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • Solved
  • Unsolved
  • Users