Help Required: Empty Data Object in onScheduledEvent Payload

Hi,

I’m trying to schedule an event in the onTicketCreate event. I created the schedule in a callback function, which is called during the onTicketCreate event. In our local environment, we are able to get the desired data in the onScheduledEvent payload when passed during the schedule function. However, when running it as a custom app, we are receiving an empty data object in the onScheduledEvent payload.

Could you please help me resolve this issue and let me know if I’m missing anything?

Please find the code below:

exports = {
  onTicketCreateHandler: async function (args) {
    console.log("Hello " + args["data"]["requester"]["name"]);
    await scheduleEvent(args);
    console.log("After scheduled events");
  },
  onScheduledEventHandler: async function (payload) {
    try {
      console.log(Date.now(), "------>time");
      console.log(
        "Logging arguments from onScheduledEvent: " + JSON.stringify(payload)
      );
    } catch (error) {
      console.error(error);
    }
  },
};


// Schedule event
const scheduleEvent = async (args) => {
  const timeGap = 6;
  //Test
  const scheduleAt = new Date(Date.now() + timeGap * 60000).toISOString();
  console.log(scheduleAt, "------->schedule at");
  try {
    let data = await $schedule.create({
      name: "ticket_reminder",
      data: {
        ticket_id: args?.data?.ticket?.id,
      },
      schedule_at: scheduleAt,
    });
    console.log(data, "--->schedule event");
  } catch (error) {
    console.log(error);
  }
};

Hi,

It’s been six days. Just following up on the previous message. Could someone provide an update on this?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.