85
Views
3
Comments
Solved
Widget Click not working in certain scenarios - Using Upload widget
Application Type
Traditional Web

Hello,

We are experiencing an issue with one of our applications where a Widget Click isn't triggering in certain circumstances. I'm attaching a sample application I built that reproduces the issue.

The application allows a user to upload a file, and should also allow them to replace that file with a different one. The initial upload is working, but the replacement of the file isn't.

We are using the Upload widget for the file upload. The Upload button uses the Submit method to trigger the "GetUploadData" screen action, which gets the data from the Upload widget. At the end of this action, we use the Widget_Click server action to trigger the "Hidden_Spinner" button. This in turn uses the Ajax Submit method to trigger the "Initiate_Load" screen action. This action does an Ajax refresh, followed by a Widget_Click to trigger the "Hidden Upload" button. This button uses the Submit method to trigger the "Upload File" screen action, which performs the file upload.

When there is an existing file, the Upload widget is initially hidden and the user sees a "checklist" item. Clicking on that item refreshes the page and again displays the Upload widget to allow the user to replace the file. In this scenario, when the user clicks the Upload button, the Widget_Click in the "GetUploadData" screen action doesn't trigger the "Hidden_Spinner" button, and the process stops there before ever reaching "Initiate_Load" or "Upload File".

I searched the OutSystems forums and based on threads I found, tried replacing the Widget_Click with JavaScript actions, but none of them worked. (I left them in the solution, but disabled them.)

I appreciate any feedback.

Thank you,

Mary Tipper

UploadWidget_v26.oml
UserImage.jpg
Mary Tipper
Solution

This issue has been resolved.

This is what I did to get this to work.

  1. Move the Upload widget with buttons to a new web block.
  2. Changed the Upload spinner button to an Ajax submit.
  3. Call a screen action from this button that triggers the spinner.
  4. Do a Widget_Click that calls a hidden upload button.
  5. The hidden upload button triggers a screen action that gets the file from the Upload widget and triggers an event to refresh the parent screen.
  6. The event handler on the parent screen performs the file save.

Mary Tipper

2022-12-30 09-46-57
Deepika Patel

Hi @Mary Tipper,

I'll analyse the issue you're having, but in the meantime, please try the following js:

"document.getElementById('"+ btnHiddenUploadFile.Id +"').click()"

btnHiddenUploadFile.Id  - is the Id of the button/link

Hope this helps!

Thanks,

UserImage.jpg
Mary Tipper

Thank you Deepika.

I have tried using the JS you provided, but it didn't work. 

It should actually be in the app I provided, but disabled, along with several different JS statements I tried.


Mary

UserImage.jpg
Mary Tipper
Solution

This issue has been resolved.

This is what I did to get this to work.

  1. Move the Upload widget with buttons to a new web block.
  2. Changed the Upload spinner button to an Ajax submit.
  3. Call a screen action from this button that triggers the spinner.
  4. Do a Widget_Click that calls a hidden upload button.
  5. The hidden upload button triggers a screen action that gets the file from the Upload widget and triggers an event to refresh the parent screen.
  6. The event handler on the parent screen performs the file save.

Mary Tipper

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.