3962
Views
12
Comments
Solved
How to assign javascript value to out-system local variable
Question

Please find the attachment, please help. 

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

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

UserImage.jpg
Sachin Sagar

Benjith Sam wrote:

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

Yeah it is working Thank you :)


2019-05-22 11-30-09
Marcelo Ferreira

Hi Sachin,

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.

Regards,

Marcelo

2018-09-23 04-03-24
Lovely Priyadarshini

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;"





UserImage.jpg
Sachin Sagar

Lovely Priyadarshini wrote:

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;"




Hi Priya,

How to  link outsystem variable to this input variable?


Regards,

Sachin





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

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

UserImage.jpg
Sachin Sagar

Benjith Sam wrote:

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

Yeah it is working Thank you :)


2021-04-15 14-49-36
Arley Silveira

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();


UserImage.jpg
Dylan Heunis

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?

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

Dylan Heunis wrote:

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?


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 Sam

UserImage.jpg
Cory Creamer

Benjith Sam wrote:

Dylan Heunis wrote:

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?


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



2020-09-24 17-45-59
Telmo Oliveira

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

2021-04-15 14-49-36
Arley Silveira

Telmo Oliveira wrote:

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

Serialize into a json string.

2025-10-06 19-50-31
Muslim Sattarov

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?

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