How to pass parameter to action using Javascript?

How to pass parameter to action using Javascript?

  

Hi,

I  have an input widget. I want to pass values to screen action using javascript. Currently im using 

extended property of widget;

But i want to pass values to the action. How to achieve this?

onkeypress:

"document.getElementById('"+EncodeJavaScript(Button.Id) + "').onclick()"

Hi Yakshith Ishawara,

You should have a variable assigned to the input widget, so when you click a button that calls a screen action, you have access to that variable and its value. I don't understand why you want to use javascript for this.


EDIT: I think I didn't understand what you wanted to do. Do you want to pass javascript variables to a screen action? If that's the case, forget what I said before and I will give you a new answer on how to do that.


Best regards,

André

Hi Yakshith Ishawara,


You can use the fake notify widget from RichWidgets to send your message through the notify, and on the FakeOnNotify screen action, get your message with the NotifyWidgetGetMessage and use the content.

Let me know if you need more help how to use it.


KR,

Ruben Bonito

There is a undocumented way of doing this. It works in both Outsystems 10 and Outsystems 11.

You can use OsNotifyWidget() function in Outsystems. Many forge components which are UI related use this API.

OsNotifyWidget() is a JavaScript function available on all Outsystems based web pages.

You can use it in combination with FakeNotifyWidget() webblock available in richwidgets espace.


High Level method:

1. Use the FakeNotifyWidget block on your screen - and bind it to the screen action you want to trigger from JS.

2. Make sure to give name to that block say "MyFakeBlock".

3. Then from JS, trigger the screenaction like this: OsNotifyWidget(MyFakeBlock.ID (must be htmlDOmID),   list of params (or use json) )

4. If you want to pass lot of paramters to screen action from JS - consider converting all params from js into a JSON object.

5. In the screen action (used by FakeNotifyWidget) call the NotifyGetMessage (which is deprecated by the way in OS 11, but not in OS 10)..and you can get the JSON/params sent from JS.

If using OS 11, I believe some alternate way has to be found.


Then in screen action you can work on the params received from JS.