Wait Process change current user page (Destination Page?)

Wait Process change current user page (Destination Page?)

  

Hello everyone!


What I'm trying to do is: When my countdown reaches zero, it change the user's current page to an "expired page".

I managed to create a Wait process with the Timeout input the same as my JQuery Countdown deadline. But in the end of that asynchronous wait event, I cant set a destination page... I cant use an action from my webpage... 


Any ideas?

Thanks is advance!

Hi Raphael, the BPT process is running on the server thus you cannot trigger something on the user's browser directly. You would have to use something like firebase to push an event into the user's browser and make it do what you want.


That being said I suspect what you're trying to achieve is better done without even using a BPT process, can you give more information on your Use Case? 

Thanks for the answer Afonso, I think you are right!

I have a JQuery Countdown running on my webpage, and here is the proper documentation

http://hilios.github.io/jQuery.countdown/documentation.html

I'm trying to set a callback action when the countdown reaches zero. It is covered in the documentation, but I'm having some problems:

This is the code from the documentation:

$('div#clock').countdown(finalDate)
    .on('update.countdown', callback)
    .on('finish.countdown', callback);

I managed to set an action inside the javascript, I hid a button and used this code to click it:

$('#"+DL.Id+"').click()

Where DL.id is my button ID.

It kinda works, but its clicking the button after 1 second in the webpage, not when the countdown reaches zero.

$('#"+defaultCountdown.Id+"').countdown({until:untilText})
       .on('finish.countdown', $('#"+DL.Id+"').click() );

In blue is my callback function.

In green is the container where the countdown is.

In red is my final date (DateTime type)

The countdown works fine, but when I set this callback it just fire up the callback :(


Raphael I think you need to enclose your click statement in an anonymous function like so 

$('#"+defaultCountdown.Id+"').countdown({until:untilText})
       .on('finish.countdown', function() {$('#"+DL.Id+"').click();} );


Otherwise that statement is being executed right when you declare the callback instead of being called later.


Afonso Aguas wrote:

Raphael I think you need to enclose your click statement in an anonymous function like so 


$('#"+defaultCountdown.Id+"').countdown({until:untilText})
       .on('finish.countdown', function() {$('#"+DL.Id+"').click();} );



Otherwise that statement is being executed right when you declare the callback instead of being called later.


Looks like that's the answer!

But I'm still working on it, now it doesn't fire the button at all, even when it reaches zero.. Maybe the problem is somewhere else... I'm still looking for it.

Is any error showing up on the console?

Where should I look for errors? In Outsystems TrueChange Window?

Well... my code is like this now:

"<script type='text/javascript'>
$(function () {  
 var untilText = '"+UntilText+"';
 $('#"+defaultCountdown.Id+"').countdown({until:untilText})
  .on('finish.countdown', $('#"+DL.Id+"').click() );

});
</script>"

This way it fires up the button immediately.

If I put the other Function call like this:

"<script type='text/javascript'>
$(function () {  
 var untilText = '"+UntilText+"';
 $('#"+defaultCountdown.Id+"').countdown({until:untilText})
  .on('finish.countdown', function() {$('#"+DL.Id+"').click();} );
});
</script>"

The countdown reaches zero and nothing happen :(

Maybe its because I have 2 functions? 

Hi raphael I think you shouildn't declare an outer function otherwise your code won't actually be executed, only declared, try it like this


"<script type='text/javascript'>
var untilText = '"+UntilText+"';
$('#"+defaultCountdown.Id+"').countdown({until:untilText})
  .on('finish.countdown', function() {$('#"+DL.Id+"').click();} );
</script>"


You can check for errors by pressing F12 on your browser and then choosing console on the menu that shows up.



Afonso Aguas wrote:

Hi raphael I think you shouildn't declare an outer function otherwise your code won't actually be executed, only declared, try it like this


"<script type='text/javascript'>
var untilText = '"+UntilText+"';
$('#"+defaultCountdown.Id+"').countdown({until:untilText})
  .on('finish.countdown', function() {$('#"+DL.Id+"').click();} );
</script>"


You can check for errors by pressing F12 on your browser and then choosing console on the menu that shows up.



Thanks again... but still doesn't work.

The code without the outer function works like the last one, it finishes the counter and does nothing. The console is empty :(


Oh well, it's hard to debug like this, if you attach your oml I can do a couple of tests. Otherwise maybe someone else can help you out )

Solution

Thank you so much Afonso Aguas, for reading my post and helping me out.

I finally found a solution:

Found another documentation for this JQuery Countdown, and there is another feature (onExpiry) that works, and my code is like this:

SyntaxEditor Code Snippet

"<script type='text/javascript'> 
 var untilText = '"+UntilText+"';
 $('#"+defaultCountdown.Id+"').countdown({until:untilText, onExpiry: forceleave}) ;
function forceleave() { 
    $('#"+DL.Id+"').click(); 
} 
</script>"

Where:

defaultCountdown.Id - Is the Container where the KQuery CountDown is.

untilText - Is the variable with the deadline.

DL.Id - Is the hidden button that is executed when the countdown reaches zero.

Solution

Glad you got it to work =)