RunJavaScript Action in Popup Editor OnNotify Action

RunJavaScript Action in Popup Editor OnNotify Action

  

Hi. I have a web screen with "add" link. Clicking "add" link will trigger a Popup Editor. The popup have an "Ok" button. Clicking "Ok" button will close the popup and notify the parent web screen. The parent web screen has an onNotify action from the Popup Editor that use the RunJavaScript Action.

I can call alert() some text based on the above setup. But I cannot use javascript to trigger a click action on a Upload Widget in the web screen. 

Is there something wrong with the setup?

Hi ,

Could you tell us what do you want to achieve. I don't understand your question.

I can call alert() some text based on the above setup. But I cannot use javascript to trigger a click action on a Upload Widget in the web screen.

what are you trying to say?  


thanks

Ramakrushna Rao Seera


I would like after clicking the "OK" button, the choose file event of the upload widget is triggered.

Hi!

After you clicking OK button the file upload process should run. For file choosing you have a dedicated button "Choose file". Don't try to make things more complicated than they are ;-)

Regards!

No that is not I need. I try rephrase my objective again. The setup is instead of clicking choose file button, the user click a link that will trigger a pop-up up. This pop-up has a text msg and OK button. Clicking the ok button will close the pop-up and by right should trigger the choose file event.

Everything is fine except the choose file event is not trigger.

I tried using Widget_Click Action to trigger the choose file event also does not work.

if you can alert() then you can also use JavaScript or jQuery selectors to find the upload widget and click on it.

If the Upload Widget has a name, it will have an Id assigned to it in the HTML, and you can trigger a click on it.

For pure JavaScript approach you just need to use something like:

document.getElementById('id').click();

or, for a jQuery version:

$('#id').click();

where id is the platform generated Id of your Upload widget.

See an example here: https://jsfiddle.net/DSARd/1

Jorge Martins wrote:

if you can alert() then you can also use JavaScript or jQuery selectors to find the upload widget and click on it.

If the Upload Widget has a name, it will have an Id assigned to it in the HTML, and you can trigger a click on it.

For pure JavaScript approach you just need to use something like:

document.getElementById('id').click();

or, for a jQuery version:

$('#id').click();

where id is the platform generated Id of your Upload widget.

See an example here: https://jsfiddle.net/DSARd/1

That was exactly what I did using the Javascript approach. But the upload widget click event did not trigger. Then I changed to alert to test it out. The alert works but the upload widget click did not...


I am stuck for many days as the RunJavascript Action seems to work for alert() or clicking actual buttons. Please see my attached OML file. Ignore the RichWidgets\Popup_upload which will be my alternative way to solve the problem. 

Hi again!

I don't know how to name this ... but it looks really strange..

I've changed your javascript to just log in console the ID of Upload1 widget 


and it logs not the ID of HTML DOM element but the HTML element itself.


That is the root cause of your issue I believe. And that is not your mistake. Looks like something wrong with the platform itself.

Correct me if I am wrong.


Tomas Baltrushaitis wrote:

Hi again!

I don't know how to name this ... but it looks really strange..

I've changed your javascript to just log in console the ID of Upload1 widget 


and it logs not the ID of HTML DOM element but the HTML element itself.


That is the root cause of your issue I believe. And that is not your mistake. Looks like something wrong with the platform itself.

Correct me if I am wrong.


Do I submit that as a bug? 


Using Widget_Click Action from RichWidgets to click the Upload Widget also does not work at all. Seems like there is some bug with the Upload Widget.

Hi Tomas

Tomas Baltrushaitis wrote:

I've changed your javascript to just log in console the ID of Upload1 widget 


and it logs not the ID of HTML DOM element but the HTML element itself.


That is the root cause of your issue I believe. And that is not your mistake. Looks like something wrong with the platform itself.

Correct me if I am wrong.

The behaviour you are observing is only because you are not using the ' around the Id when you log it to the console. Inspecting the HTML element will show that it does in fact have an id attribute with the correct contents.

John Alvin Salamat wrote:

behavior of browser - Outside of such user-initiated events, file dialogs cannot be opened programmatically.

No way to go around it in outsystem? 


Meng Wye, Lavin Lim wrote:

John Alvin Salamat wrote:

behavior of browser - Outside of such user-initiated events, file dialogs cannot be opened programmatically.

No way to go around it in outsystem? 



I'm not aware of any workaround with the native <input type="file">. Found a js library though that looks promising - https://www.npmjs.com/package/file-dialog. You might want to give it a shot