971
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)? 

2020-09-26 09-10-18
Danny Eeraerts
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

2026-02-26 06-29-24
Rahul
 
MVP

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

2020-09-26 09-10-18
Danny Eeraerts

Rahul Sahu wrote:

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

 Hi Rahul

I think this  example is exclusive for mobile. Isn't it? I'am looking for a solution for web. 

Thanks Danny

 

2021-03-18 21-03-15
Benjith Sam
 
MVP

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

2020-09-26 09-10-18
Danny Eeraerts
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

2021-03-18 21-03-15
Benjith Sam
 
MVP

Danny Eeraerts wrote:

 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

 Hi Danny,

To store the TimeZone value in the session variable, you just have to map the hidden Input widget Variable property with the Session Variable (of Text Data type) instead of Local Variable as shown below

See this sample app

Hope this helps!


Regards,

Benjith Sam

2020-09-26 09-10-18
Danny Eeraerts

Benjith Sam wrote:

Danny Eeraerts wrote:

 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

 Hi Danny,

To store the TimeZone value in the session variable, you just have to map the hidden Input widget Variable property with the Session Variable (of Text Data type) instead of Local Variable as shown below

See this sample app

Hope this helps!


Regards,

Benjith Sam

 Thanks to Benjith Sam

 

2021-03-18 21-03-15
Benjith Sam
 
MVP

Danny Eeraerts wrote:

 Thanks to Benjith Sam

You are welcome, Danny :)

I'm glad that I could be of help :)


Regards,

Benjith Sam

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