JavaScript and server action for Mobile Apps

JavaScript and server action for Mobile Apps

  

Hi,

How to call server action from JavaScript? 

I've tried the "$('#"+LogoutDiv.Id+"').click();" but the action isn't valid. Is this the correct syntax?

Thank you


Does LogoutDiv have a link or a jQuery event assigned to it? If it doesn't you're not gonna be able to trigger a click on it.


If you're looking for a way to automatically logout the user through client control, take a look at this component: https://www.outsystems.com/forge/component/1880/session-expire-warnning/

João Melo wrote:

Does LogoutDiv have a link or a jQuery event assigned to it? If it doesn't you're not gonna be able to trigger a click on it.


If you're looking for a way to automatically logout the user through client control, take a look at this component: https://www.outsystems.com/forge/component/1880/session-expire-warnning/


Hi, and thank you for the reply. 

I've try the example but I have problem in implementing them. Since the example is in web app and I'm developing for Mobile app. If in web app, screen action is as same as client action in mobile apps?

Solution

Hello Sharizad,

In Mobile, you can't call a server action from JavaScript (not even in Web, to be honest).
You can call a "Client" action in Mobile App.

Here is the documentation: https://success.outsystems.com/Documentation/10/Extensibility_and_Integration/JavaScript/Extend_Your_Mobile_App_Using_JavaScript

Cheers.


Solution

Eduardo Jauch wrote:

Hello Sharizad,

In Mobile, you can't call a server action from JavaScript (not even in Web, to be honest).
You can call a "Client" action in Mobile App.

Here is the documentation: https://success.outsystems.com/Documentation/10/Extensibility_and_Integration/JavaScript/Extend_Your_Mobile_App_Using_JavaScript

Cheers.


Thank you for the reply and I've conducted a few test for this javascript implementation with the calling of client-action. 

My idea, create a new client action and place a server action in it. On top of that, create another OnClick action with javascript on the logic and the javascript contains the command to call that new client action. The result for these test:

1) Javascript with simple command(alert): Successful (Report: https://docs.google.com/document/d/1KZFVlCV4Qm9ZNHtC7u6IQpjy1SSw3706anSxCmVx_7o/edit?usp=sharing)

2) Javascript with triggering server-action: Not successful (https://docs.google.com/document/d/1geaWRnadaCozIO8xFKq9I_Mglw-YdDPhzBnVXVOjK-0/edit?usp=sharing


If anyone knows how to solve this, let me know. 


Hi Sharizad,

Can I ask why can't you just call the client action directly and need to use JavaScript?

For no 2, I tested it and it works.

It's just the effect of logout is not immediate.

After clicking the button, then try to navigate using menu to screen that need authentication (no anonymous).

You will be kicked out to Login screen.

Jorge Martins wrote:

Hi Sharizad,

Can I ask why can't you just call the client action directly and need to use JavaScript?

Hi, 

This is a small chunk of my bigger task. The main idea is to make 5-min automated logout for mobile apps (only if user stays idle that long). The idea and suggestions that I've gathered lead me to implying javascript and in completing this issue and I need to call server-action (User_Logout) in the javascript. Unfortunately, the development of this 5-min automated logout isn't successful so I'm breaking the problem into smaller chunk and this is one of it (I believe it is).

But if you have suggestion or anyone has any idea on automated logout for mobile apps, feel free to reply. 

Harlin Setiadarma, thank you and now I get it. 

Thank you


Understood.

So what you want is to limit idle session duration... you may be able to achieve what you need through simple configuration in Service Center. Please read this https://success.outsystems.com/Documentation/10/Managing_the_Applications_Lifecycle/Secure_the_Applications/Configure_Mobile_App_Authentication to learn about mobile session authentication (useful for banking apps, for instance)