Problem with schedule job

Hey everyone!
I’m trying to create a scheduled job with no success, it’s not running.
The function has been tested and working, (triggered by button and not by schedule job)
I have a backend file called “DatabseJobs.jsw” , and the function called “syncCalendar()”
The jobs array is :


// /backend/jobs.config
{

  "jobs": [ // Define up to 20 different jobs

    {
      "functionLocation": "/DatabaseJobs.jsw", 
      "functionName": "syncCalendar",
      "description": "sync yachts calendar from CYA every day ", 
      "executionConfig": {
        "time": "08:00",
      }
    }
  ]
}

Can anyone help please?

Maybe you’d like to post the function itself.

Thanks for your reply!
This is the function but as i mentioned before its working and i don’t think the problem is here… its just not executing

export function syncCalendar() {
 return wixData.query("yachts2").find().then(results => {
        results.items.forEach(yacht => {
        let yachtCalenderArray = [];
 

 // get calender
            getYachtCalender(yacht.yachtId).then(calendarResult => {
                calendarResult.calendar.forEach(invite => {
                    yachtCalenderArray.push({"startDate" :                    invite.yachtStartDate, "endDate" : invite.yachtEndDate});
                });
                yacht.yachtCalender = yachtCalenderArray;
                wixData.update("yachts2",yacht).then(aprroved => {
                    console.log("updated")
                }).catch(onRejected=> {
                    console.log("declined")
                });
            });
        })
    })

@orhirschhorn14 If you say it runs when you call it, so the issue is probably somewhere else. And I can’t help…
But by the way I’d say the function could be written in a simpler & shorter way so it’ll be easier to debug.

Instead of using forEach(), you could do something like:

export function syncCalendar() {
 return wixData.query("yachts2").find().then(results => {
  let yachtCalenderArray = [];
 return Promise.all(results.map(e => getYachtCalender(e.yachtId)));
})
etc...//use another Promise.all
//...
  • bulkUpdate in the end.

@jonatandor35 thank you the answer,
my problem is that the function is not executing by the schedule job.
not the function itself

@orhirschhorn14 you know the time you set is UTC. Right?
Have a look at the site logs (if you connected it to Google Stackdriver maybe it logged an error.)

@jonatandor35 Thanks again, can you please provide more information about how can i connect the site to this tool and check the logs?

@orhirschhorn14 Dashboard > Settings > Site motoring (and continue from there)

@jonatandor35 Did that, what exactly am i looking for? there is a lot of log types, which one has information about the schedule tasks?

@orhirschhorn14 I guess an error on jobs.config . Or with the keyword “jobs”.
You can also look in here (I haven’t read it):

https://www.wix.com/corvid/forum/community-discussion/debugging-scheduled-jobs-in-corvid

By the way, someone said there it only works with .js files.
I know that in the specification it says that jsw files are supported as well, but you should try having it in .js (Please let me know if it solved the problem).

@jonatandor35 You were right, this is the log :

E 2020-10-08T16:*3Z Failed to parse job configuration for site 'website-11': parsing jobs.config error: wrong JSON format 

Any idea why this is happening?
what is wrong with the jobs.config json format?

@orhirschhorn14 Try to remove the comment ( // Define up to 20 different jobs ) and remove the comma after the time.

Remove the first comment as well

@jonatandor35 it worked! thanks a lot for your help and patience