Trigger Screen Action on Javascript

To have a javascript function calling a screen action 

1. Put a button on the webblack and hide it using css  (style="display: none;") 

2. Javascript function force the click action on that button when certain action is performed: $target.parents('.something').find('.otherthing').click();


But the click() seems not working.

Hi,

Have you made certain that the find() is obtaining your button? Have you tried writing the same, but with an Id selector instead of class?

$('#" + TheButtonYouWantToClick.Id + "').click();

Hi QIUYAN LI,

Try Using widget click action available under rich widgets 

for more info go through this link https://www.outsystems.com/forums/discussion/27124/how-to-force-a-button-click-using-javascript/#Post99899

Regards,

Koushik

Hi QIUYAN LI,


Make sure you are getting element to generate event.  you can select element by id, class etc.


Thanks

Hi,

The best way of calling a screen action on JS is with Fake Notify. To accomplish that follow this steps:

  • Add a FakeNotifyWidget (from RichWidgets) to the block and create an OnNotify action for it
  • Name it (the FakeNotifyWidget) and on the onblur event of the desired input add the following:
    OsNotifyWidget('<FakeNotifyWidget>.Id', '<message>')
  • On the OnNotify action you can get the <message> using the NotifyWidgetGetMessage() built-in function and treat it accordingly

Regards,

Marcelo

QIUYAN LI wrote:

To have a javascript function calling a screen action 

1. Put a button on the webblack and hide it using css  (style="display: none;") 

2. Javascript function force the click action on that button when certain action is performed: $target.parents('.something').find('.otherthing').click();


But the click() seems not working.

do you have any error in console? Have you tryed this with a link instead of a button?

BR


Carlos Gonçalves wrote:

QIUYAN LI wrote:

To have a javascript function calling a screen action 

1. Put a button on the webblack and hide it using css  (style="display: none;") 

2. Javascript function force the click action on that button when certain action is performed: $target.parents('.something').find('.otherthing').click();


But the click() seems not working.

do you have any error in console? Have you tryed this with a link instead of a button?

BR


Hi, 

thank you for the reply.

No console error. 

And I have doubled check that I am able to click on the button, but not stop at the debugging point inside the screen action.

 It is a link <a>.

Do I need to return any Notify?