27
Views
7
Comments
Solved
How to bind the result of Javascript function in Web App to Outsystem local
Question

I'am new to Outsystems. Can anyone explain me how to bind the return value of the Javascript function "<script> Intl.DateTimeFormat().resolvedOptions().timeZone;</script> to a outsystems local variable in a web app.(Not Mobile)? 

Rank: #1743
Solution

Benjith Sam wrote:

Hi Danny,

For your use-case (w.r.t Traditional Web Application) follow the below mentioned implementation steps...

Steps:

1) Define an input widget and set the Name property value (e.g. Input_TimeZone)

2) Set the Input widget style property in the extended properties section

style = "display:none;"

or

set a StyleClass with "display:none;" definition

3) Define the below mentioned JS within an expression widget (set the Escape Content to No)

Script Snippet

"<script>
    document.getElementById('" + Input_TimeZone.Id + "').value = Intl.DateTimeFormat().resolvedOptions().timeZone;
</script>
"

4) The Local Variable mapped with the Input Widget  (i.e. Input_TimeZone) will get assigned with value from the JavaScript code

See this sample app 


Hope this helps you!


Regards,

Benjith Sam

 Hi, I reach the same result as you. Thanks for this. But I want the result (textvalue) (for me this is "Europe/Brussels") in a session variable. It's not clear for me where to assign the textvalue to a session variable.

 Thanks again

Danny

Rank: #90

Hi Danny,

set output parameter in javascript like below image


Use this output in local variable -

use this local variable on screen.

Regards

Rahul Sahu

mvp_badge
MVP
Rank: #96

Hi Danny,

For your use-case (w.r.t Traditional Web Application) follow the below mentioned implementation steps...

Steps:

1) Define an input widget and set the Name property value (e.g. Input_TimeZone)

2) Set the Input widget style property in the extended properties section

style = "display:none;"

or

set a StyleClass with "display:none;" definition

3) Define the below mentioned JS within an expression widget (set the Escape Content to No)

Script Snippet

"<script>
    document.getElementById('" + Input_TimeZone.Id + "').value = Intl.DateTimeFormat().resolvedOptions().timeZone;
</script>
"

4) The Local Variable mapped with the Input Widget  (i.e. Input_TimeZone) will get assigned with value from the JavaScript code

See this sample app 


Hope this helps you!


Regards,

Benjith Sam