set an execution time code
# 🤝help
q
Hello, I would like that at 00h each day a column of my data table is updated automatically and each box of this column is set to 0. Is it possible and if yes how to do? thank you.
f
Hello Nicolas, I believe this is doable. What I would recommend doing is using the code feature of tables https://botpress.com/docs/cloud/studio/tables/#operations-on-tables---via-code There a couple paths you could run with you, could just update everything to 0 with the code or you could delete all rows so there is no data and it is fresh for the next day
To trigger this I would use a Fixed schedule trigger
So I would have the trigger and its node separate from the rest of the flow in main
Here is what my Fixed Schedule Trigger looks like
I just used hte code generator to delete the records from my table
Let me know if you have any questions
q
thank you very much, it's great. I'm just having trouble creating the code. I want that when the code executes all the cells of the column "Nombre d'essaie" of the data table "LoginUtilisateursTable" are 0.
it's ok, i managed to make the code but the trigger is not good, it doesn't trigger.
I'm trying to get closer to the time of day to see if it works, but it doesn't seem to be working.
@flat-plumber-75402 Hi, I've got a problem, the trigger doesn't work, I've tried changing the time, nothing works, what can I do?
f
Hello @quick-agency-16863 First point Cron expressions are UTC time So if I wanted it to trigger at midnight Eastern time I would need it to trigger at 04:00 UTC everyday which cron expression is 0 4 * * *
What does the node you are connecting to your trigger look like?
Also your bot has to be published for the trigger to fire. Even if you have published before you if you add or change the trigger you need to hit publish again.
And for the last piece I just used the execute code functionality and described what I was after and it generated it for me
Let me know if you have any questions
Ah ha Sorry @quick-agency-16863 Nicolas my execute code laziness on using the generate code was mislead this time. Try this
The selector you will have to create prior. My selector here returns all rows.
q
thanks to the marcxhe code now. But I can't get the trigger to work, is that normal?
f
Test Results with trigger set for 18:42 this is the before the trigger fired
this after
Here is what the trigger looked like
And the trick is you have to publish after editing your trigger for the changes to take affect
q
ah ok I live in France I want it to run in France so I just have to base it on UTC time?
@flat-plumber-75402 thank you very much it works now
f
You are most welcome! Yes base it on UTC time. Let me know if you have any other questions.
a
I I was having the same problem. My trigger didn't work. I just used the UTC time relative to my region. Thank you very much.👏
6 Views