Trigger download at timer end - Traditional Web

Hi all,

We have a requirement, in traditional web, where the user clicks a button on a screen, that button will trigger an action that is supposed to do some stuff ASYNCHRONOUSLY, allowing the user to keep working on the screen on other things and so on...
So I was thinking about waking a timer in that action. But when the action behind that button ends (so when the timer ends) the PDF file that will result from the timer should be downloaded.


From my knowledge, you cannot use a download widget at the end of a timer flow...
Any ideas?

Thanks!
Paulo

Solution


I think you should use BPT instead of timer. In BPT after doing your operation you can give callback to notify UI about the completion of operation and enable the download button in UI.

How to notify from BPT to UI : https://www.outsystems.com/forums/discussion/60214/notify-ui-interface-from-bpt/

regards

Hi Paulo ,

In tradition you can do it by writing some JavaScript code in preparation of the page using HttpRequestHandler >> RunJavascript  action. some thing like below 

"setInterval(function(){OsNotifyWidget('"+ ProcessFakeNotify.Id +"', '')}, 3000)"

That would poll the request every 3 second and you can add a FakeNotifyWidget.

You can also refer the URL shard by vikas https://www.outsystems.com/forums/discussion/60214/notify-ui-interface-from-bpt/ 

That uses same method for polling the request and to notify the screen

And on FakeNotify action of FakeNotifyWidget you can check the task completion of timer by below methods 

1. Create your entity and a boolean attribute against the logged in user, set that as a false before the timer run and set as true after successfully completed 

2. The Timer systems entities you can get the status of the time 

3. You can also check the file existence on the server.

Hope this will help.

Best Regards

Devendra





Yes. Actually download widget is available on client side (client action) only. timer will run on server side so you can't use download widget there.

regards


Yes that's my point, so is there any alternative to tackle my requirement?

Solution


I think you should use BPT instead of timer. In BPT after doing your operation you can give callback to notify UI about the completion of operation and enable the download button in UI.

How to notify from BPT to UI : https://www.outsystems.com/forums/discussion/60214/notify-ui-interface-from-bpt/

regards

Paulo,

You are correct you cannot use a download widget at the end of timer as the timer runs on different process. 

However you can break this process in 2 steps 

1. When a user click on button trigger the timer that will generate the file

2. A web block that will continuously check the file is generated or not if generated than you can show the download icon.

Hope that would help

Best Regards

Devendra

Hi @Devendra Baghel ,

I like your idea however i'm not following how would step 2 be implemented. How would you continuously check in a WB if the timer ended for example?

I think timer is not good solution here, because timer may have only limited instance for the platform and in your case there may be many concurrent requests.


Hi Paulo ,

In tradition you can do it by writing some JavaScript code in preparation of the page using HttpRequestHandler >> RunJavascript  action. some thing like below 

"setInterval(function(){OsNotifyWidget('"+ ProcessFakeNotify.Id +"', '')}, 3000)"

That would poll the request every 3 second and you can add a FakeNotifyWidget.

You can also refer the URL shard by vikas https://www.outsystems.com/forums/discussion/60214/notify-ui-interface-from-bpt/ 

That uses same method for polling the request and to notify the screen

And on FakeNotify action of FakeNotifyWidget you can check the task completion of timer by below methods 

1. Create your entity and a boolean attribute against the logged in user, set that as a false before the timer run and set as true after successfully completed 

2. The Timer systems entities you can get the status of the time 

3. You can also check the file existence on the server.

Hope this will help.

Best Regards

Devendra





Thanks a lot, I will try that, and it makes sense!

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