In NAV 2009 I used a custom control add-in to enable timers in the Role Tailored Client. NAV 2013 ships with a control add-in that is called PingPong. In upgrading one of my solution to NAV 2013 I wanted to remove the custom control and introduce the PingPong instead.
The control requires a name and as the standard functionality does I use the name PingPong. The code I had in the – OnControlAddin trigger is now moved to a new trigger, PingPong::Pong. The new timer does not work the same way the old one does. The method used is similar to the new method in the Job Queue where the sleep function is used instead of a regular timer. By executing Currpage.PingPong.Ping(500) a new thread is started that sleeps for 500 milliseconds and then fires the trigger PingPong::Pong. Hence the add-in name. When all required code in this trigger has been executed another Ping is required to thow the next ball.
This is all good if the application is only using one timer. I saw that if I already had one PingPong working then in the subsequent page PingPong did not work. The good news is that the timer control add-in that I created for NAV 2009 also works in NAV 2013. The page that I open from the page running PingPong will continue to use the timer add-in that originated from Freddy and I changed a little bit.
Hi Gunnar,
Thanks for your example.
I have a problem using the PingPong Add-in maybe you can help me.
I want to display on a list page a field “Time Left” (type duration) which looks like a count to zero (HH:MM:SS). So i want to refresh my page each second using the pingpong add-in.
Is it possible ?
Thanks.
Michael.
Sure it is possible. Should be something like this.
PingPong::AddInReady()
CurrPage.PingPong.Ping(1000);
PingPong::Pong()
TimeLeft := TimeLeft – 1000;
CurrPage.PingPong.Ping(1000);
I tried something like this but unsuccessfully !
My page is temporary and i fill it when i open the page (OnOpenPage trigger)
Here the function “Fct_UpdatePage” called in the trigger:
//>>begin function
DELETEALL;
RecGServiceHeader.RESET;
RecGServiceHeader.SETRANGE(“Document Type”,RecGServiceHeader.”Document Type”::Order);
RecGServiceHeader.SETFILTER(Status,’Finished’);
IF RecGServiceHeader.FINDSET THEN
REPEAT
CLEAR(Rec);
TRANSFERFIELDS(RecGServiceHeader);
“Time Left” := Fct_CalcTimeLeft;
INSERT;
UNTIL RecGServiceHeader.NEXT = 0;
ASCENDING(FALSE);
SETCURRENTKEY(“Time Left”);
//<<end function
And this the code in the add-in triggers
PingPong::AddInReady()
CurrPage.PingPong.Ping(500);
PingPong::Pong()
Fct_UpdatePage;
CurrPage.PingPong.Ping(1000);
what's wrong ? 🙁
Are you trying to update the whole page, not just a global variable that you display on the page ?
If that is the case you will need to emulate F5 being pusshed twize.
For example with a function
SendKey(‘{F5}{F5}’);
SendKey(Key : Text[30])
Wait := TRUE;
IF ISCLEAR(WShell) THEN
CREATE(WShell,TRUE,TRUE);
WShell.SendKeys(Key,Wait);
where WShell is Automation ‘Windows Script Host Object Model’.WshShell
No only the Time Left field i want to update.
But nothing happened ! for the moment the only solution i have it is to add a button which run my function “UpdatePage” when i press on.
You can try the Timer Add-in from my blog. https://dynamics.is/?p=1054
Is your timer Add – in supported in the the WEB Client ?? DO you know of one to use if yours is not supported ? Thanks
Is pingpong supported in nav web client?
No, only in Windows Client Fabian
Thank you Gunnar, i have another question, does ping pong use server ram? it seems that the page running ping pong does not free up the RAM. over time the application server’s ram grew to nearly 21GB.
have you had such experience?
Has anyone noticed if you start a Page with RUNMODAL the PingPong never activates?
i.e. MyPingPongPage.RunModal; walking through the code you can see the Addon activate, but it never fires.. Changing the above to MyPingPongPage.Run; everything works fine.
I need the RunModal to work, as I don’t want the user straying from that page..
Yes Indy, this is true. Therefore I sometimes use the timer I shared some time ago as a PingPong replacement.
Hi even with your timer the event does not fire if in RunModal… Was anyone able to fix this?
Yes Taddeo, my timer works in all both cases.
Does ping pong works only in active page or it doesnt matter?
Only in the active page. You will have to go for the non-threading timer if you need a timer on nonactive pages. https://dynamics.is/?p=1054
Hi Gunnar,
Why did you add a PingPong Field to a Page? I did the same thing but was unable to select the PingPong assembly in the ControllAddIn Property of the page. Do I have to add the PingPong assembly as a Global Variable too? Thanks in advance.
The PingPong control-addin needs to be in you control-addin table. You don’t need toe pingpong assembly in a variable.
We’ve used pingpong previously in NAV2013,NAV2016 is there an issue with using pingpong in NAV2017 to refresh cue controls linked to flowfields in role centers? They no longer seem to refresh. Only if place CurrPage.ACTIVATE(TRUE) but then z-order of any open pages is changed.
Thank you
Regards
Scott
Are there any other open pages using PingPong in NAV 2017?
This is absolutely remarkable. I’ve been looking for a replacement for the OnTimer trigger forever. I’m incredibly grateful for this post. I tried it out and it works exactly as advertised. Thank you, Gunnar!