Call server action from server action

Call server action from server action

  

In a website, I'm trying to isolate my server actions to have a clean layout.  For example I have a wizard, and I would like to create the following actions:

  1. Server-side validate step 1
  2. Server-side validate step 2
  3. Button 1:  Server action that calls action #1, then navigates to step 2.
  4. Button 2:  Server action that calls action #2, then navigates to step 3.

I realize all this logic can be put into one server action, but I would like to compartmentalize the code by purpose to make it easier to manage.  This is commonly done when coding by putting redundant code in a function and calling the function instead.  In the mobile apps, you can easily do this with client actions, but on the server side it seems you cannot call one server action from another on the same page.  Is it possible somehow?

Solution

Hi David,

I'm assuming that when you are mentioning server actions, you mean Screen Actions...

If that is the case, you can not directly call a Screen Action from another Screen Action. 

You can use a Screen Action to click on a button (using Widget_Click) that is bound to another Screen Action which in fact will be one Screen Action calling another Screen Action. But that implies a new http request and that is not a good idea in terms of performance.

To compartmentalize the code you can use Server Actions. And in that case you can use Screen Actions to call the Server Actions and also you can use Server Actions to call other Server Actions. What can be an issue with the Server Actions is that they do not have access to the variables on the screen or queries in the Preparation. Thus, you have to pass those values as parameters. Also, you can not do Ajax Refreshes in Server Actions.

Cheers,

José 

Solution

Hi There,


Do you why the rest of the useful server actions do not show up in my entities? In one picture I see all the actions like delete, get, update, etc. In the other I can only see the create action.


thanks for the help


Gonzalo

Gonzalo Labarca wrote:

Hi There,


Do you why the rest of the useful server actions do not show up in my entities? In one picture I see all the actions like delete, get, update, etc. In the other I can only see the create action.


thanks for the help


Gonzalo

Hi,


I think it's related to the fact that there's no Primary Key in the LazoBoards entity?


cheers,

Joao


Gonzalo Labarca wrote:

Hi There,


Do you why the rest of the useful server actions do not show up in my entities? In one picture I see all the actions like delete, get, update, etc. In the other I can only see the create action.


thanks for the help


Gonzalo

Gonzalo,

That is not really related to the topic of this post, but... the entities that only have the GetEntity Action have the Expose Read-Only property set to Yes.

Cheers,

José