Mobile App - List and Detail Screen - CreateorUpdateWrapper

Mobile App - List and Detail Screen - CreateorUpdateWrapper

  

hi there,

I am wondering this part of exercise:

When we call directly the GetUserId() function [A] and indirectly in a wrapper [B], aren't they all generated in the client and call the UserID in the Outsystem server? So, what are the differences? What does Run Server Action widget mean - is it action defined in the server side (like web) or action in the client side (socket programming) that call a server? Thank you.


regards,

IB


Hello I Box,

A server action is executed server side.
In this case, it will be called from the client side, what will generate a request to the server.

The recomendation is to do server side because of security reasons. In the server, the current user do not can change things, like fake its own user id (that he could try to do it client side).

Cheers,
Eduardo Jauch

EDIT:

You would call GetUserId from inside the ServerAction, not pass it as parameter.

Hi IB,

Client actions run on the device. Server actions run on the server.

If you call a Server action from a Client action a REST service will be called from your device to your server and the Server action will run.

Regarding the user, you can call the GetUserId in a client action or in a server action. If you call it in a client action it will not go to the server to get the User Id. It will get it locally from the device. If you call it inside a server action (that was called from a client action) then it will get from the server. Usually they are the same.

The issue is that the information on the device can be tampered. And someone can impersonate a user and set a different userid in the device. On the other hand if you set the userid on a server action it will not be possible to change the user, since that logic is done on the server.

Cheers,

José

Thank you Sirs,

- It is said that the a client call a REST service (web service) when it call server action, does it mean a web server is also has to be installed in the Outsystems platform to communicate with the client when the client do server action?

- if GetUserId() is called in a client action, it will get it locally from the device; if it is called from server action, it will get from the server. I have a question, is it correct that the function is defined as a part of client code? and if it is inside a client action (like SaveOnclick) that userid is called from that local device(using web protocol or else?), if it is put it a wrapper (server action) then that function will do a REST service to the server?  


Thank you in advance.

regards,

IB   

Hi I Box.

1. No, there is no need to install anything extra. The system takes care of the REST communication for you. It is transparent.

2. If you call GetUserId from inside the Server Action, as the entire server action will be executed in the server, the call to GetUserId will also be made server side. Only the server action method call is done through REST.

Cheers,
Eduardo Jauch

Hi Eduardo,

Thank you very much, for the server action your explanation is very clear.

What about to call GetUserId() in the client action? Is it correct that:

- there are two implementation of GetUserId() - one for client side and one for server side? Although i get it from the same source (Built-in function - same signature).

- there are two copies of UserID - one in the client side (not secure) and other in the server side (secure)?

-  Invoke_AserverActionWrapper invocation is done using REST protocol?

- What about client-side GetUserId() invocation? What protocol is used? Is there Cordova inside the client side (handphone)?  


regards,

IB


Solution

Hello I Box.

1. This could be of use:

https://success.outsystems.com/Documentation/10/Reference/Logic/Built-in_Functions/Roles_Built-in_Functions#GetUserId

So, while it seems to be the same Action, they aren't. In Client side, it goes after the UserId locally (local storage). If you are calling it from Server side, it is a different code that will look for the id in the server side database.

2. Kind of. The authenticated user id is stored locally (it is important to work offline).

3. Yes.

4. Don't know. But as client actions are (I think) translated as JavaScript (mobile uses React as its main engine), I would say that it is not really a "protocol". It is just JavaScript code that will be executed and will get data from the local storage. The Cordova is what allows the application (not being really a native application), to use mobile resources like camera, sensors, etc).

Cheers,
Eduardo Jauch


Solution

Hi Eduardo,

Thank you very much for your clear explanation. 

I think you are correct that the Javascript retrieve the local storage like a common function (although i am still confused as javascript in my understanding is always a web application ... may be the REACT engine take over the rest?). 

I found this statement "OutSystems native apps are built on top of the Apache Cordova framework, a framework that enables using any native device API through the use of plugins." in this link https://success.outsystems.com/Evaluation/Mobile/02_What_native_capabilities_does_OutSystems_support

and the picture is below and i have difficulties in understanding what this means - is it the Cordova is built in the handphone or just access from external (codova) site?:

regards,

IB

Hi I Box.

Like it is said, the native application is built over cordova. But If I understood well the documentation, the cordova is used ONLY if you are using external plugins (that will be compiled and bounded to your app).

The rest is all done through REACT. A mobile OutSystems application is an Hybrid application. In fact for most of what you could think, is almost like a Web Application that runs in your mobile, not over the web.

Regarding your draw, no. It is not external do devide. 

Cheers,
Eduardo Jauch

Thank you very much Sir.

May be I'll open another forum thread just for Cordova when I have reached that lesson.

regards,

IB