I am attempting to create an app with a scheduled sync of data pulls on a recurring schedule. I can get the handler to trigger when running locally, but I cannot get the event to run once the app is installed. I am just simply consoling the data so I can see when the app runs right now, nothing too crazy yet. The code snippet I have in Server.js is below:
I made the changes recommended and added 5 minutes to the scheduled at time to account for the fact that scheduled events must be scheduled in more than 5 mins from installation, however, it still did not trigger in the UI. This will be a recurring schedule end state. Just trying to get the schedule to trigger in the UI in general.
createSchedule: async function(args) {
console.log(args)
var currentDate = new Date();
var schDate = new Date(currentDate.getTime() + 300000);
// console.log(date.toISOString())
try {
let data = await $schedule.create({
name: "ticket_reminder",
data: {
ticket_id: 10001
},
schedule_at: schDate.toISOString(),
repeat: {
time_unit: "minutes",
frequency: 5
}
});
console.log(data)
}
catch (error) {
console.log(error)
}
}
As mentioned, the scheduler would have been triggered. Since schedulers are used in the serverless application, you can find the logs in the “View Log” section.
Click on “Settings” and then select “View Log.” Kindly refer to the screenshots below for reference.
Like @Anish mentioned this is a serverless event and whenever the scheduler is triggered you would find a log of the console.log(payload) as your handler function is using it.
Let me know if you can see the logs or if you are having any trouble.
The issue is that there is not a payload in the logs at all, usually I can receive the args or payloads in the logs with other handlers but not this one. With the code above this is this logs for the app as of this morning (the console should be happening every 5 mins based on the code above):
Again, I can get it to trigger when hosted locally, but I cannot get anything to trigger when the app is uploaded. Why is this not working for me? Am I missing something?
Can you confirm if the scheduled event is getting created when you install the app, and also can you share the snippet which is invoking createSchedule method?