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)?
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
set output parameter in javascript like below image
Use this output in local variable -
use this local variable on screen.
Regards
Rahul Sahu
Rahul Sahu wrote:
Hi Rahul
I think this example is exclusive for mobile. Isn't it? I'am looking for a solution for web.
Thanks Danny
Danny Eeraerts wrote:
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
Hope this helps!
Thanks to Benjith Sam
You are welcome, Danny :)
I'm glad that I could be of help :)