In a NodeJS project, I have several Server Actions that I want to use in a Schedule Action?
Can I do this and what action in Action Step can I run them from there?
Sorry, I didn’t quite understand you - I meant actions purely on the server side according to a schedule
You can’t call server actions directly in the Scheduler.
However you can call library actions there, so just define your steps in library actions and call them.
Is there a way to quickly use the code from the Server Action and move it to the Library without having to rewrite it again?
There’s currently no way of converting a server action into a library item.
It’s sad, I’ll have to duplicate a lot of work ;(
As a workaround, you can call the server action using the API extension. So in your scheduler action step, add the API action and in the url use the server action API you want to use. Note that you have to pass the full url including the domain name and port.
This way you don’t have to recreate the server action as libraries.
Yes, I also thought about this as a backup option, although of course all this looks so clumsy and unnatural within the framework of one system.
One clarifying question - if we call a Server Action via an API from a schedule, and it is protected by Security Restrict, will it be executed? That is, is the Security Provider ignored in this case?
Vote for it to be added here
It’s possible to copy code from a server action into a library action. However, you have to be pretty comfortable in code view and understand which parts to copy. I also leverage the Bull Queues extension and regularly add Server Actions via scheduled actions as API calls to a queue.
Thanks for the interesting information, I’ll have to try to master this somehow
I recommend starting with a simple server action and mirror the same setup in the library action. You should be able to see which parts are the same. Then copy/paste, test etc.