Difference between Screen action and server action

Difference between Screen action and server action

  

What is the theoretical and logical difference between screen action and server actions? May be a very basic question.

Screen action = client side (runs in the ui/browser)

Server action = server side (runs on the server)

Does that help?

Might be worth running through this course that covers all of this in detail

Hi Dan,

Screen Actions allow you to run logic when the user interacts with the screen, such as clicking on a button or a link.

In OutSystems you can create Server Actions to encapsulate the logic that implements the business rules of your application and use them in other actions, such as Preparation actions, Screen Actions or other Server Actions:


See for more details.

https://success.outsystems.com/Documentation/10/Developing_an_Application/Implement_Application_Logic/Actions_in_Web_Applications#Screen_Actions

Solution

@Dan: What you are saying is correct for Mobile Apps, but not for Web Apps. For Web Apps, Screen Actions also run server-side.

@Ajith: I've written here about screen actions: "A Screen Action is an Action that is called by Screen Elements, e.g. a Button or a Link (or by a Widget as part of a Notify). It has direct access to the Screen's Variables and Preperation." Note that for Web Apps, Screen Actions can't call each other, but for Mobile Apps, they can. Screen Actions have always Screen scope, so only elements of the Screen can access them.

On the other hand, Server Actions, like shoeb said, are used for encapsulating reusable logic. The can be Public, i.e. they can be Referenced by other eSpaces.

Solution

Kilian Hekhuis wrote:

@Dan: What you are saying is correct for Mobile Apps, but not for Web Apps. For Web Apps, Screen Actions also run server-side.

@Ajith: I've written here about screen actions: "A Screen Action is an Action that is called by Screen Elements, e.g. a Button or a Link (or by a Widget as part of a Notify). It has direct access to the Screen's Variables and Preperation." Note that for Web Apps, Screen Actions can't call each other, but for Mobile Apps, they can. Screen Actions have always Screen scope, so only elements of the Screen can access them.

On the other hand, Server Actions, like shoeb said, are used for encapsulating reusable logic. The can be Public, i.e. they can be Referenced by other eSpaces.

Referring to this old question, so if I have two buttons on the screens. one when you click will save and redirect to page A, the other will save and redirect to page B. So they shared the same 'save' function. In this case since screen actions cannot be shared, should I create a 'Server Action' particular for this page for such sharing purpose?


EDIT #1\:

I just attempted to copy over all the things for such 'save functions' from a screen action into a newly created server function. So understandingly a lot of errors popped up for not having the variables. That totally makes sense so this is not the right way to do?

I should just recreate a new Screen Action and copy everything over to the newly created Screen Action instead of the idea of reusing actions?


Stephen Li wrote:

Kilian Hekhuis wrote:

@Dan: What you are saying is correct for Mobile Apps, but not for Web Apps. For Web Apps, Screen Actions also run server-side.

@Ajith: I've written here about screen actions: "A Screen Action is an Action that is called by Screen Elements, e.g. a Button or a Link (or by a Widget as part of a Notify). It has direct access to the Screen's Variables and Preperation." Note that for Web Apps, Screen Actions can't call each other, but for Mobile Apps, they can. Screen Actions have always Screen scope, so only elements of the Screen can access them.

On the other hand, Server Actions, like shoeb said, are used for encapsulating reusable logic. The can be Public, i.e. they can be Referenced by other eSpaces.

Referring to this old question, so if I have two buttons on the screens. one when you click will save and redirect to page A, the other will save and redirect to page B. So they shared the same 'save' function. In this case since screen actions cannot be shared, should I create a 'Server Action' particular for this page for such sharing purpose?


EDIT #1\:

I just attempted to copy over all the things for such 'save functions' from a screen action into a newly created server function. So understandingly a lot of errors popped up for not having the variables. That totally makes sense so this is not the right way to do?

I should just recreate a new Screen Action and copy everything over to the newly created Screen Action instead of the idea of reusing actions?


Hi Stephen,

In server action either you have to pass entity object or value as parameter and execute your logic based on that values. you would not be able to find controls on server actions. bcoz of this reason you are getting lots of errors.

But for your case i suggest to take input parameter in your save screen action and pass values to identify on which page you redirect to user after performing you save logic. Just call same save screen action on both button click.


Hope this helps....

Regards

Shoeb

Shoeb Khan wrote:

Stephen Li wrote:

Kilian Hekhuis wrote:

@Dan: What you are saying is correct for Mobile Apps, but not for Web Apps. For Web Apps, Screen Actions also run server-side.

@Ajith: I've written here about screen actions: "A Screen Action is an Action that is called by Screen Elements, e.g. a Button or a Link (or by a Widget as part of a Notify). It has direct access to the Screen's Variables and Preperation." Note that for Web Apps, Screen Actions can't call each other, but for Mobile Apps, they can. Screen Actions have always Screen scope, so only elements of the Screen can access them.

On the other hand, Server Actions, like shoeb said, are used for encapsulating reusable logic. The can be Public, i.e. they can be Referenced by other eSpaces.

Referring to this old question, so if I have two buttons on the screens. one when you click will save and redirect to page A, the other will save and redirect to page B. So they shared the same 'save' function. In this case since screen actions cannot be shared, should I create a 'Server Action' particular for this page for such sharing purpose?


EDIT #1\:

I just attempted to copy over all the things for such 'save functions' from a screen action into a newly created server function. So understandingly a lot of errors popped up for not having the variables. That totally makes sense so this is not the right way to do?

I should just recreate a new Screen Action and copy everything over to the newly created Screen Action instead of the idea of reusing actions?


Hi Stephen,

In server action either you have to pass entity object or value as parameter and execute your logic based on that values. you would not be able to find controls on server actions. bcoz of this reason you are getting lots of errors.

But for your case i suggest to take input parameter in your save screen action and pass values to identify on which page you redirect to user after performing you save logic. Just call same save screen action on both button click.


Hope this helps....

Regards

Shoeb

That's a great suggestion. Thanks for that and I think that'll be what I am going to do!