Testing onScheduleEvent via FDK - Incorrect data structure issue

I am having some issues when testing onScheduledEvent. My payload looks something like this

  "account_id" : 3,
  "event"  : "onScheduledEvent",
  "region"  : "US",
  "timestamp"  : 1586872210,
  "domain" : "https://xxxxxxxx.freshservice.com/",
  "data" : {"name": "sync"},
  "iparams": {

here is my callback

  onScheduledEventHandler: function(payload) {
    console.log("Logging arguments from onScheduledEvent: " +  JSON.stringify(payload));
    if(payload.data.name === 'sync') {
        //perform task

The console is displaying that it cannot find data.name in the payload, not does the payload include anything other than iparams (which I believe is added itself)

Logging arguments from onScheduledEvent: {"iparams":{...}
    if (payload.data.name === 'sync') {

TypeError: Cannot read property 'name' of undefined
    at Object.onScheduledEventHandler (server.js:2508:22)
    at server.js:1:70
    at server.js:1:274
    at Script.runInContext (vm.js:133:20)
    at ProductEvent.sandboxExecutor (/home/device42/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/lib/event_handler/framework.js:221:25)
    at ProductEvent.execute (/home/device42/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/lib/event_handler/framework.js:215:10)
    at ProductEvent.execute (/home/device42/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/lib/event_handler/framework.js:296:13)
    at handler (/home/device42/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/lib/event_handler/framework.js:340:11)
    at handleRequest (/home/device42/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/lib/routes/beevents.js:97:3)
    at Layer.handle [as handle_request] (/home/device42/.nvm/versions/node/v10.18.1/lib/node_modules/fdk/node_modules/express/lib/router/layer.js:95:5)

Am I using the product simulation page correctly?

Hi @osanchez

Unfortunately, this is a bug that occurs in the local testing scenario. The dev team is working on the fix. I will keep you posted on the progress.

1 Like

Hi @osanchez,

This has been fixed in FDK 6.2.7. Kindly update your FDK to the latest version using the fdk version command and let us know if it works :slight_smile: !

1 Like