arshath.h
(Arshath H)
September 29, 2020, 5:02am
1
Hi Community,
I am having issues working with schedules & accessing Data Storage API from the serverless app.
When i tried using schedule and db in server.js, it throws an error ReferenceError: $db is not defined
& ReferenceError: $schedule is not defined
I have attached the screenshots of the error. Please help me resolve this issue.
Schedule Code Snippet :
$schedule
.create({
name: `service_task_${data.ticketId}`,
data: { taskData: data },
schedule_at: time
})
.then(
(data) => console.log(data),
(err) => console.log(err)
)
DB Code Snippet :
$db.set("ticket:101", { taskId: 15213 }).then(
function (data) {
console.log(data)
},
function (error) {
console.log(error)
}
)
DB Error :
Schedule Error :
FDK Version :
Thanks,
Arshath
Hi Arshath,
May I know under which event handler is this snippet written?
2 Likes
arshath.h
(Arshath H)
September 29, 2020, 5:52am
4
Hi @ManiDeepak_Vandrangi ,
Thanks for your reply.
I have used it in onScheduleEvent & my custom method in server.js.
exports = {
events: [{ event: "onScheduledEvent", callback: "onScheduledEventHandler" }],
onScheduledEventHandler: function (payload) {
handler.scheduleHandler(payload)
},
serviceTask: function (payload) {
handler.serviceTaskHandler(payload)
renderData()
}
}
Hi Arshath,
Are you trying to invoke this event from custom installation page? If so, in custom installation, we do not support data storage($db) and schedule($schedule).
2 Likes
arshath.h
(Arshath H)
October 2, 2020, 1:14pm
6
Hi @ManiDeepak_Vandrangi ,
I have used the $schedule & $db in server.js file.
BTW, i am not receiving the error anymore in my machine. I don’t know what was the reason for the error. And, don’t know how it resolved automatically .
Thanks for your reply.
1 Like
arshath.h
(Arshath H)
May 17, 2021, 11:20am
8
Hey Folks,
We are facing the same error again
Is the error same as above mentioned screenshots for the above mentioned snippets? If so, are you using the latest version of fdk?
2 Likes
arshath.h
(Arshath H)
May 18, 2021, 5:44am
10
@ManiDeepak_Vandrangi Yes same error, we receive this often. Then suddenly it resolves automatically. Could you please help find us the issue?
prithvi
(Prithvijit Dasgupta)
May 18, 2021, 7:37am
11
@arshath.h does this happen in FDK events testing or when you try to use the end to end testing feature?
2 Likes
arshath.h
(Arshath H)
May 18, 2021, 8:55am
12
@prithvi This happens in FDK events testing.
Hi Community,
In local, recurring schedule It’s working properly. Error occurs only time based schedule.
Solution:
Publish and install your custom app in portal. It should works proper.
thanks.