How to call screen action in Javascript in Javascript property in outsystem web?
Hi Naveen,
Please find a working example as an attachment. The below steps were followed:
"OsNotifyWidget('"+ MyFakeNotifyWidget.Id +"', 'A message from Javascript!')"
Result: If you execute a request to that webscreen, a feedback message will be triggered directly with some text and the message sent from JS code.
Hope this helps!
Regards,
Nordin
Nordin Ahdi wrote:
Hi Nordin,
Thank you very much for your response..! Its working.
regards,
Naveen
Hi NaveenRaj,
In Traditional Web you can use one of these options to call a screen action from JS. And AFAIK you cannot trigger the screen actions from the Javascript property of the module.
One option is to use the FakeNotify web block from the RichWidgets module. This way you can use the following JS function to call the OnNotify screen action of the web block.
OsNotifyWidget('<FakeNotifyWidget>.Id', '<message>')
For more information check out this post.
An alternative, which I have not tried myself, is to use this Forge component to invoke web block events directly from JS. For more info check out this post and the instructions on how to use the component are on the Forge components' overview page.
Hope this helps.
Hi Nordin Ahdi,
Thanks for the response. I used FakeNotifyWidget and used OsNotifyWidget(....) inside JavaScript in JavaScript property of webblock. Its not working. So am trying with that Forge Component.
NaveenRaj wrote:
Can you share an example OML with your implementation? I have used the FakeNotify widget in the past with success so I know for sure it works.
The steps are described in this post too.
Kindly find my sample attachment.
Hi NaveennRaj if you want to call an action from the JS use this
$(".SpecifiClassToTheButtonYouWantToCall").click();
Add this class to a hidden button and the destination of this button is the action you need
Cheers
Carlos Lessa
Carlos Lessa wrote:
Sorry I had a wrong understanding on this answer but you can also use it and combine if this method bellow
From the properties: declare a function and call it, check the pic
Call the action by invoking the function, in this case, I use the Extend property of a button to call it
and the result when I click
Hi Carlos Leesa,
I tried this way. It also working. Thank you very much. This is simple one.
Might I just add that Carlos' solution is indeed a simple one, but it is not considered a best practice to add inline Javascript. This must be avoided as much as possible.
You can read more about this here.
You are right, Anyway thank you guys for supporting me.
You're welcome Naveen. That is what we are here for.
Enjoy developing with OutSystems!