10
Views
8
Comments
Is it possible to render output variable value from JS node in action?

I've included logic in my client action for an input box. The logic change the numbers render transforms them and then saves the back to the input box to update as someone types. When I place this value into the output parameter and assign the output value to a local variable, the expression will not render the data in the output variable.  is there another way to send the output variable from an input action event back to the screen. I only have one screen BTW. 

any help is appreciated!

mvp_badge
MVP
Rank: #75

Hi Ashley,

I'm not able to understand the requirement completely. Is it that

1) The client action is the OnChange handler of the input control?

2) Within the client action what does exactly the JS node is defined with (I mean the JavaScript)?

3) Is it that you are trying to update the Input widget value using the JS node, which is define in the input widget OnChange handler action flow?

4) Or is it that you are just capturing the manipulated value as an Output parameter of the JS node to the local variable and showcase the same using the expression widget?

If possible could you please share some screen shot of the implementation or any rough mockup of the actual use-case in order to understand the use-case much better.


Kind regards,

Benjith Sam

Rank: #18384

Thank you for your response Ben! 

It would be #4. If I don't try to pass the output parameter to the expression with assign, the expression captures the first character/num I input and then right after, does not capture the rest of the value. I'm guessing because my input is being manipulated and not being sent back to the expression widget. 

If I assign the local variable to the output parameter, the expression doesn't render anything. 


ScreenShot20201211at1.07.33AM.png

mvp_badge
MVP
Rank: #75

Hi Ashley,

Thank you for sharing all the requested information. I have tried to solve the mentioned use-case.

See this sample app | Input Formatter JS

Refer the attached .oml file

The single issue which I observed is that the input control is not showcasing the '$' symbol (after some input length exceed it is showing the '$'). I also logged the input control value and it does have the '$' symbol but in actual the input is not displaying the '$', no clue why it's happening so..


Hope this helps you!


Kind regards,

Benjith Sam

RWALabInputJSFormatter.oml

Rank: #128

Hi Ashley,

I get the impression that you intend this piece of javascript to run, every time the input changes.  You have to choose if you want to do that entirely in javascript, or in an Outsystems OnChange event.

you are probably doing both here, I can't really tell from your screenprints, but if you are trying to populate output of the javascript node, and after that trying to assign that output to something else, I think that's what you're doing, right, we are looking at the OnChange.

So what you are doing, is inside the OnChange, which in itself is already going to react to changes to the input, you are defining another event listener with the "addEventListener" part.

Everything that comes inside that function definition, isn't going to get executed there and then, but the next time an event occurs.  As a consequence, everything you do there to the $Paremeters.Out1 will be done to a local variable with that name inside that javasript event listener, not to the output of your Javascript node.

So, in other words, loose the whole add event listener bit, and you should be fine.

Dorine