Ever wondered why Outsystems have elements or features which doesn’t have much use, or development won’t be blocked without them. I know you must have thought about it quite a few times while working in such an efficient low-code platform, especially if you are a beginner.
And one of those elements that could be the reason for your confusion is client action and screen action. These two similar-looking actions are very different in many factors, and today we will discuss all those factors that differentiate them with each other.
Before we understand the difference between screen action and client action, let’s first have a brief look at what screen action and client action is.
What is Screen Action?
Screen action is an action that can be triggered because of human intervention in the screen or website to perform a particular task. For example, on the screen, there is a button. Whenever a user clicks on the respective button, the action that will be triggered will be the screen action that was assigned to it.
In simple language, we can say that a screen action is an action that is created inside a particular screen, which can be triggered because of a widget or another screen action.
What are Client Actions?
On the other hand, client action is created inside the logic portion of the screen, inside the client action folder. This action works as a screen action, but its scope is not limited to a screen but can be used on different screens at the same time.
Even when client actions and screen actions can have somewhat similar logic with their same components, the scope and motive of both actions are very different.
Difference Between Screen Action and Client Action
Now that we know what client and screen actions are and where you can create them, let’s dive further to differentiate them, so that you can be clear when you should use which action.
Scope
The scope of screen action is limited to the respective screen it has been created. For example, if there is any action called “Save” in a “Feedback” screen, then that “Save” action can’t be applied anywhere else other than the “Feedback” screen.
On the other hand, client action can be used in multiple screens and blocks without creating another action like it; in other words, a client action can be used inside the module it is created as well as in the other modules where there is a dependency of the particular action.
So from both the differences we can say that, the scope of screen action shrunk to its screen only while client action is accessible from all the screens and sometimes from different modules too.
Reusability
When we talk about the reusability factor in screen action, then screen actions are reusable only inside that particular screen where it is created, which means screen actions can’t be reused outside the screen they are created.
But in client action, the reusability of the action is very high as a user can reuse the same function multiple times, which helps in reducing the number of multiple actions having the same logic by just creating a single client action.
Accessibility
The screen actions can access a lot of things from the screen, like the widgets of the screen, and aggregates of the screen. If we take it simply, then screen action can access all the elements which is inside that screen.
On the other hand, client action has no access to screen elements like widgets or aggregates; to get the data in client action, developers need to use input parameters.
So now we can say that screen actions have accessibility to screen elements while client actions have no accessibility to any element in the screen, not even aggregates.
Direct Use
When we are talking about the direct use of the element, we mean to say that it can be bound from a widget directly and does not need any action to connect it.
So if we talk about screen action, then it can be used directly with the widgets of the screen. For example, if we can bind the button on click action directly with a screen action and does not mandatorily need other actions to bind it.
But client action cannot be accessed without a screen action, which means client action can’t be used directly by any screen widget.
So we can say that screen action can directly bind with a widget, but client action needs a screen action to bind it with a widget.
Parameters Allowed
We all know that screen actions have only two types of parameters, Input parameters and Local variables. You cannot create any output parameter for a screen action.
But in client action, there is no restriction for any kind of parameter, you can use all types of parameters, that is, Input parameters, Output parameters, and Local variables, all can be used inside a client action.
So we can say that the Output parameter is restricted in screen action, but it can be used in client action.
Implementation Restriction
When we are talking about Screen action, it can be implemented anywhere in that particular screen, but if you try to put screen action inside a client action then it is not allowed, as the scope of screen action is just inside that screen but client action’s scope is much wider in comparison to it.
But if you are thinking that it will be the same with client action, then you are wrong, because you can use a client action inside a screen action’s flow without any problem.
So with this we got action variation between screen action and client action, that is, a client action can be used inside a screen action, but the vice versa is not possible.
Conclusion
So, after differentiating all the factors of screen action as well as client, we can say that there are use cases when a user should use a client action or a screen action.
For example, if a user has to use an action multiple times across the screens or modules, then they should use client action as it supports reusability of the actions, but if you have to write a logic that is used only once, then you can create a screen action inside that particular screen only.
This way you can try, decide which action you should use and which one you shouldn’t.
I hope this article provides you with a better understanding about what are the difference between client action and screen action. If you’d like to suggest something or have any doubts, don’t hesitate to comment on your question; we have experts in Outsystems who can solve your problems in a snap.
And if you want more knowledgeable articles, then do subscribe to our newsletter, so you can read our latest articles.
Happy coding!