Wait for few minutes in action

Hi All,

I have one action inside this, i am using one timer which is storing data in entity and then same records i need to display on screen.As timer is separate process my display data not in sync with stored data.So I want to wait for few seconds to complete timer process so that my action to fetch data can get sync data.

Do we have any way to add wait before my action.

Thanks in advance .


Manish


 




Hi Manish,

Create a webblock with following integer input parameters:

On the javascript property of the webblock paste the following javascript:

function prepare_autorefresh(refreshLinkId, periodInMilliseconds) {
    window.setInterval(function() {
        var link = document.getElementById(refreshLinkId);
        if (link != null) {
            link.click();
        }
    }, periodInMilliseconds);
}


Then include the webblock on your screen, and set the input parameters. The RefreshLinkId needs to be the id of a refresh link that you can conditionally display. In the destination of the link create an action that does a refresh of the aggregate and ajax refresh of the part that displays the data on the screen. Note, the link must have method set to 'Ajax submit'.


Using visibility of the link you can swithch the firing of the action on and off. If you just want it to keep firing, then just add the hidden css class to style instead of conditioning it with an if on visibility.

Regards,

Daniel


Of course the Firebase component, as described by Roman, is also a a workable solution, but requires extra component dependencies and additional configuration. 

Solution

Hi Manish,

Why do you want to have your saving logic in timer if it is just a few seconds?

You have couple options: 1) use ajax timer available in forge to ping your server for the updates once in a while 2) use Firebase component to notify client when something is done. 

I prefer 2nd option. 

Solution

Daniël Kuhlmann wrote:

Of course the Firebase component, as described by Roman, is also a a workable solution, but requires extra component dependencies and additional configuration. 


Hi Deniel,

Thanks for update Yes,Your solution is good where we need to refresh the screen with latest sync data.But I forgot why i need batch if its firebase requirement.

Manish

Roman Tkachenko wrote:

Hi Manish,

Why do you want to have your saving logic in timer if it is just a few seconds?

You have couple options: 1) use ajax timer available in forge to ping your server for the updates once in a while 2) use Firebase component to notify client when something is done. 

I prefer 2nd option. 

Hi Roman,


Thanks for guiding me,Actually that is existing code and they were using timers for firebase activity and I was also following same approach but now I realize I don't need any timer for direct action.Thanks again my problem resolved now.

Thanks And Regards,

Manish Pandey