Hello,
I am trying to call a custom even from a trigger. However, the event is never called and the program just skips over it.
The event itself is asynchronous and the trigger is set to run every 60 seconds.
Based on the examples and the code found in your documentation, my trigger and custom event look like this. Any idea what might be the problem, and if so, how can I fix it and access the value returned by the event?
Custom Event
/* global Backendless */
/**
* @param {Object} req The request object contains information about the request
* @param {Object} req.context The execution context contains an information about application, current user and event
* @param {Object} req.args
*/
Backendless.ServerCode.customEvent('kctuevent', function(req) {
//add your code here
console.log("Success, the event was called");
return { test: "Passed" };
}, true);
Trigger
/* global Backendless */
/**
* Notification timer.
* It is executed according to the schedule
*/
Backendless.ServerCode.addTimer({
name: 'Notification',
startDate: 1468854300000,
frequency: {
schedule: 'custom',
repeat: {'every':60}
},
/**
* @param {Object} req
* @param {String} req.context Application Version Id
*/
execute(req){
//add your code here
console.log("Timer");
var successHandler = function(res) {
console.log(res);
console.log("Success");
};
var errorHandler = function(res) {
console.log(res);
console.log("Error");
};
Backendless.Events.dispatch("kctuevent", {arg: "DRAGOS"}, new Backendless.Async(successHandler, errorHandler));
}
});