Server action not available in expression
Application Type
Mobile, Reactive
Service Studio Version
11.50.12 (Build 48233)

Why can't we use a server action directly in an expression even though it's function property set to Yes?

Hi Marcio,

I did refer to that chain already but I couldn't find what I am looking for there.

mvp_badge
MVP

Hello there Krishnnambal,

Hope you're doing well.

As you know, Mobile/Reactive Web Applications are quite different from Traditional Web Applications.

In a Traditional Web Application, everything works Server Side. Screen Actions for instance are executed Server Side, the screen itself is also constructed Server Side, and that's why you can call a Server Action defined as a Function directly in a expression.

In Mobile/Reactive Web Applications, you have a Client Side vs Server Side model. Screens are no longer constructed Server Side and Screen Actions work Client Side. In the Client Side, only Client Actions defined as Functions can be used directly in expressions. That's why you cannot call a Server Action defined as a Function because these run Server Side.


As suggest by Rahul in the URL provided by Márcio, an alternative would be the creation of a Data Action, call the Server Side function in here and assign the result to an output of the Data Action. Afterwards, you may use that output in an expression of the screen.


1) Create a Data Action (this is executed Server Side, that's why you can call Server Side Functions in here):

2) Inside the Data Action, use the Server Side Function and assign the result to an Output:

3) Use the Output of the Data Action in an expression of the screen:


The Data Action will be executed Server Side and asynchronously. After its execution, the expression of the screen will be updated.


Hope that this helps you!


Kind regards,

Rui Barradas

Hi Rui,


Thanks for the reply. :) 

I knew the work around but was curious to know the the reason. Thought something in deep than just the client and server architecture.

mvp_badge
MVP

Hello again :)

In this case, it's all about the Client vs Server model.

In Traditional Apps, Screens are constructed Server Side and sent to the browser afterwards. During this process, Server Side Functions can also be called and evaluated.

In Reactive and Mobile Apps, Screens are constructed Client Side, that's why you can only use Client Side functions.


Kind regards,

Rui Barradas

Hi Rui, 

 Is the way how the code gets translated has anything to do with this? Server actions are interpreted as ASP .net code. Is this the reason we can't use it directly on screens which are nothing but HTML. Since Client actions are JavaScript, they can be used directly. Please correct me.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.