Please find the attachment, please help.
Hi Sachin,
In addition to Marcelo Ferreira reply, here is a small practical implementation to make it more clear.
Sub: To assign JavaScript value in OutSystems local variable using JavaScript.
Sections:
1) Screen consists of
Local Variable - InputValue
Screen Action - Show, ShowUpdateValue
Expression Widget - MsgExp, UpdatedMsgExp
2) Input widget - You can set the input widget style = 'display:none;' as per your requirement.
3) Show Button Action -
4) Show Updated Value Button Action:
5) Final Output: (Link)
Hence you can use the assigned JavaScript value i.e. by local variable InputValue
Hope you understood my explanation. Let me know if you have any questions!
Regards,
Benjith Sam
Benjith Sam wrote:
Yeah it is working Thank you :)
You need to assign the js variable to a text box. The variable linked to that textbox will get the value. You can hide the text box with CSS.
Marcelo
Hi sachin,
I agree with Marcelo
Steps you have to do
take one input widget and set its display to false and name it hiddenInput
now link your outsystem variable to this input variable
Now In javascript part your code should be
"var jsvalue='Test';
document.getElementById(' "+hiddenInput.id+" ').value=jsvalue;"
Lovely Priyadarshini wrote:
Hi Priya,
How to link outsystem variable to this input variable?
Sachin
You may want to call change() after setting the value in case you need to do something on onChange()
SyntaxEditor Code Snippet
$(""#"+input_id+""").change();
Hi there
The solution above works, but I need to do it within a logic server action (hence no UI input boxes available).
How do I go about that?
Dylan Heunis wrote:
Hi Dylan Heunis,
Sorry for the late response. As per the above stated solution it gets executed in the server action i.e. the JavaScript code in which the JS value is assigned to the OS local variable is written in the server side, I mean on the Button onClick action flow. Here the input widget on the UI is just a medium through which we are assigning the JS value to the Input widget container (local variable) by which it is mapped. In your case you can hide the input box from the UI-end.
Hope you understood my explanation :-)
Thanks & Regards,
Benjith
But what if you wanted to do it in a server action that isn't a part of the Interface/UI - like an OnSessionStart action?
Cory
Hi everyone;
How should we proceed if, instead of a value, one needs to pass a whole list (or even a list of lists) from a JS to an OutSystems Local Variable?
Thank you all,
Best regards;
Telmo Oliveira
Telmo Oliveira wrote:
Serialize into a json string.
Benjith Sam, sorry for offtop, but may I know how you shared your implementation? I am new to OutSystems, so I wonder how I can make my environment visible globally?