Passing Values outside Javascript
Question
Application Type
Mobile

Hi,

I am using a Javascript to run a stopwatch and i want this stopwatch to run multiple times based on the requirement set by the user.

So When it starts to run, i have a button to "Stop" this stopwatch counter.

        ticker = setInterval(tickFunc, 1000); 

$parameters.TimerId = ticker;

I use the property "clearInterval($parameters.TimerId);" to stop this counter when "Stop" button is clicked

This is working fine without any issues.

Now if the User want this to run 3 times in loop, then what happens is that, the "Ticker" value keeps changing every time inside the JavaScript and i am not able to assign this value outside this Javascript, as the Stop action calls a different Client Action inside which it clears the TimerId ( inside Client Action, there is a Javascript that runs " clearInterval($parameters.TimerId); " ).

So is it possible to assign the value of Javascript variable "ticker" directly to a local variable of that particular screen inside the javascript, so that every loop, i have the Local variable updated with the new TimerId and i can clear it.

Hope my question is clear.

Thanks

Solution

Hi Guys,

Thanks for your reply. I have gone through the link shared by Jose and i could see lot of methods mentioned there which may or may not work. But i saw one of the comments to pass the value to a container and then hide the container so that it is not visible to users.

So i worked on top of that and found my Solution.

So what i have done is, First i created a container with id "TempContainer" and then i passed the value of "ticker" to this container

document.getElementById($parameters.tempContainer).innerHTML = ticker;

Then in the Stop Action, i created a variable to hold the value of this container and then i used it for clearinterval function.

temptimerid = document.getElementById($parameters.tempContainer).innerHTML

clearInterval(temptimerid);

This solved my issue. 

Thanks Guys for suggestions.

Hello @Learn It,

The link in the above post indeed has what you are looking for. Just in case the multiple options presented in that article has you unsure, here's another link that is dedicated to the subject - Extend Your Mobile and Reactive Apps Using JavaScript - OutSystems. The following section of this article should resolve your question.


In the example above, basically you can then assign $parameters.OutEmail to a local variable.

Hope this helps. Cheers!


Solution

Hi Guys,

Thanks for your reply. I have gone through the link shared by Jose and i could see lot of methods mentioned there which may or may not work. But i saw one of the comments to pass the value to a container and then hide the container so that it is not visible to users.

So i worked on top of that and found my Solution.

So what i have done is, First i created a container with id "TempContainer" and then i passed the value of "ticker" to this container

document.getElementById($parameters.tempContainer).innerHTML = ticker;

Then in the Stop Action, i created a variable to hold the value of this container and then i used it for clearinterval function.

temptimerid = document.getElementById($parameters.tempContainer).innerHTML

clearInterval(temptimerid);

This solved my issue. 

Thanks Guys for suggestions.

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