Can I Convert An Existing Normal Server Action to a Library Action?

Thank you for creating Library Actions… I am just investigating them now and they are exactly what I need for some parts of my project!

I have a complex server action with 150 lines of actions which I’d like to make into a Library Action… is there any way to convert it either in Wappler or by changing a few lines of code in the PHP…? :thinking:

2 Likes

Not sure if that is possible.

But what I can suggest is a simple copy paste.

  1. Create a new library.
  2. Add two steps to it and save.
  3. Open exiting server action in editor. Select JSON part & copy.
  4. Open library server action in editor. Select JSON part & paste.
1 Like

Oh @sid, that is really interesting… does that work? It could save me hours of time… I have quite a few existing complex server actions that could make amazing Library items!

Yes. Its all JSON. You can even copy stuff from PHP to Node too without any issues usually.

1 Like

Start and test with something small, then have at it. :grin:

Thanks @sid… am just playing with it now! :slight_smile:

Can you feed back here how it went?

Looks like it went bad, resulting in a false bug report:

we do NOT advice doing things like that.

I thought that might be the case which was why I was keen to hear how it went.

Works like a dream.

150 lines of complex code converted to a Library action and working perfectly.

1 Like

I thought you went to far with copy-paste with all the how-tos and bug reports on Library Server Actions.
Glad to see you got it working. :smile:

One thing as George noted in other post, copying GET/POST params is not going to work. Something new for me too. I didn’t realize this, but luckily when I did this, I actually just copied the STEPS key’s JSON.

This option would make a fantastic feature @George - hint hint Can you add or copy a server connect / API action to the library?

2 Likes

Am just playing around with this again…

I’m finding that if you copy a standard server action to the Library folder (dmxConnect/modules/lib) and delete all of the input parameters and hit save, then it automatically gets converted to a Library Action!

Not sure if this is a feature or an accidental side effect of how things work right now but it is very useful and saves lots of fiddling around with code.

2 Likes