Creating Reusable Actions with Server Connect Library


Server Connect Library allows you to create reusable actions, which can be included in any of your API Actions:

This way you can define some complex actions once, use input parameters for the values and then execute or include them in different API Actions, when needed.

Using Library Actions

There are two ways of using Library Actions - Include and Exec:

Both of them run the selected Library Action but in different ways.

Include Action

The Include Action allows you to include a Library Action Inline in your API Action. It allows you to pick data from inside the Library Actions - as if they were steps in your API Action.

We will show you a simple example of how this works. First, right clicking Library in the Server Connect panel and select Add Library Item:

Then add name for it:

Let’s add a database query in the steps. Right click steps and add a Database Single Query:

Setup the query options:

And Save your Library Action when you are done:

Open your API Action, where you want to include the Library Action and right click steps:

Open Core Actions and Select Include Action:

Then click the Action Picker button:

And select your Library Action:

Now, to demonstrate the ability to pick data from the included action, we just add a set value step, so right click on the include step:

And add Set Value:

Click the dynamic data picker:

And you can see the data from your Library Item available in the picker:

Select the data you need and click the Select button:

Save your API Action:

Then let’s run the server action in the browser to preview the results. You can see the data from the Library Action as well as the Set Value step showing what we’ve selected:

Exec Action

The Exec Action allows you to execute an Library Action as a single/separate action and only get its output data. Using Exec Action you can pass values to the input parameters.
A good use case can be defining a complex image manipulation workflow as an Library Action and use input params to control the resize/crop width/height, image url and other options.

We will show you another simple example, this way demonstrating how the Exec Action works:
First, right clicking Library in the Server Connect panel and select Add Library Item:

Then add name for it:

Defining Input Parameters

With Exec Action you can use input parameters to your Library Action. This way you can send data from your API Actions to the Library Action, when you execute it.

Let’s create an input parameter. Open Input, right click $_PARAM and add new variable:

Add a name to it:

Now we can use this parameter in the steps of the Library Item. For example, we can filter a database query.
Right click steps:

Add a Single Database Query:

And setup the query options:

We’ll use the parameter we created to filter the query, so open the Conditions tab:

Select the column you’d like to filter by:

Then click the dynamic data picker button:

And select the input parameter we’ve created:

Click OK:

And save you Library Action:

Then open the API Action you want to execute your Library Action in. Right click steps:

Open Core Actions and select Exec Action:

Click the action picker button:

Select your Library Item and click Select:

Assigning Values to Input Parameters

All your Input Parameters from the Library Action will appear here:

You can use a dynamic or static value. The dynamic value can be any dynamic value available in your API Action - GET or POST Parameters, Session Variables, a Query Result etc.

We enter a static value just for testing purposes:

And then we can preview the results in our browser. You can see the Exec results, as well as the rest of your server action steps (if any):


That’s how to use the Library Actions to create reusable actions, which can be included in any of your API Actions. Check this new functionality and let us know what do you think :slight_smile:


Waited for this so long! Thank you very much Wappler-Team!

We’ve got to reorganize our cms, but at the end this will speed up maintenance and development a lot.


Can someone give real life examples as to when to use this? I feel it is a powerful tool yet I can’t think of a single use case. In my biggest project I likely have well over 100 Server Actions and not one of the is the same with the exception of Database Connection.

I think I am missing the point or something powerful.

Well any set of steps that you are using in more than one server action. Just the simplest and useful example - an image processing action.

  • Load image
  • Resize image
  • Save resized image
  • Crop Image
  • Some other image step(s) here
  • Save cropped image

Why would you add this to multiple server actions / admin pages in your CMS, when you can have it on one place and add all the options as input params - path, width, height, save locations…

Another example - logging data / storing it in the database when the server actions or pages are being executed - pass all data using input params.

There are many examples, where you need to create a library item and reuse it across multiple actions and pages.


I’ve just used it to reduce loads of actions. I’ve created one for inserting a record into an activity table. I can now use that across everywhere to save the activity easily. Just created a few PARAM variables and it worked first time exactly as I expected it to.



Thank you for this tutorial. I have a question:
Assume I have an API (formerly known as server actions) called “foo” and a Library Item called “bar”.

The API foo will invoke the Library Item bar.

Other than how you pass parameters to one or the other, is there any difference, in performance, security, or other, between

  • foo invoking bar using an exec action (Core Actions > Exec Action), and
  • foo invoking bar using an API invocation action (API connector > API Action)?

Many thanks,


Library items can only be included in API Actions (server actions) using the Exec and Include steps.

What are the difference between the two and when would you use each of these?

Brad, I believe it’s pretty well explained in the first post of this topic:

Thanks Teodor, it’s well explained if you know what it means. I think I understand the include action but the exec action still is over my head. Remember, I am still a Wappler dummy. :wink: :beers:

Well include acts like it’s adding the library item’s steps in your server action steps. You can access them from your server action steps.
Exec runs the library item like a separate action - its steps are not available in the server action and not included inline. You just send input data to it and wait for the output data.

1 Like

Thx Teodor for the prompt answer.
So, what about this variant:

foo again is the calling API

bar_exec is a Library Item, that would be called by foo as an Exec Action.

bar_api is another API, that would be called by foo as an API Action

Is there any difference between them? Other than the obvious one about where each of the bar functions would be located, I can probably see a much simpler syntax when calling an Exec Action instead of an API Action.

Is there any other benefit or tradeoff?

Many thanks!


Many thanks!

Include is just include of all those actions inline ( like a header include in html)

While exec is executing as a single item with parameters. Your library item is acting as one blackboard action ( even if it has multiple steps inside)

1 Like

In general if you use either include or exec to run a library action - the results are exactly the same.

It is that when you use include the actions step will be visible in the current action as if they are there, while in exec they are blackboard as a single action with only output data.

1 Like

Hmm, ok, thanks I understand Included Actions. That makes sense. So, if I make a change to a Library item that is included in several API Actions it will effect all API Actions that use this library action?

I can see this being both awesome and yet dangerous. Interesting.

Thx @George, but I am trying to understand the differences, if any, between using an Exec Action in a calling API and calling another API using API Action.

with great power comes great responsibility :grinning:

1 Like

And it’s the same as you are using PHP includes on your pages for header/footer etc. - if you edit your header content the changes go on every page using this include.

@brad so tried to quickly show this in a diagram … hope it explains things better:


Thanks again, Teodor. You guys have once again done an amazing job. :beers:

I have a bit better understanding now. Now, it’s on me to figure out how I can use this in my workflow.

Again, thanks to team Wappler. It’s truly amazing what you guys do on a weekly basis.


Hello! thanks for the diagram. I would suggest to include it in the documentation. I read the documentation and I also had to read this entire thread to clearly understand the difference between using include and exec.

BTW, awesome features and awesome explanation. :nerd_face: