0

I have an unusual requirement at a client that requires a timeout if the user does not interact with a specific form for a certain amount of minutes (the time for the timeout is parameterized in a parameters form). Essentially if nothing is clicked/saved/interacted with on the form, it triggers a call to a menu item and bring the user to a landing page form.

My question: Is there a master or parent event that I could write that will capture all of the events of a specific form along with all formdatasources and formcontrols that would allow the timer to reset as long as the user is interacting with and using the form to prevent the timeout and page change from occuring prematurely if the user is still using the form?

I've tried post handler on FormControl.lostFocus(), but that is denied.

[PostHandlerFor(classStr(FormControl), methodStr(FormControl, lostFocus))]
public static void SNS_FormControl_Post_lostFocus(XppPrePostArgs args)
{

}

Results in: enter image description here

I've also checked out the FormRun class, tried to see if subscribing to the onTask() delegate would provide any benefit (it didn't).

I have not thoroughly looked at FormRun but I'm worried that I'll have to resort to subscribing to a ridiculous amount of events both on the form controls and on the form datasources just to capture enough "interaction" events.

rjv
  • 1,058
  • 11
  • 29
  • You may consider poking around `C:\AOSService\webroot\Scripts\Controls\Form.js` in a Dev box and search `TimeoutDialog` to see some of the code that MS uses for the canned "Are you still there?" dialog. No clue if that's of any use. – Alex Kwitny Jul 10 '19 at 23:38
  • 2
    Something similar could be done with the `setTimeOut` method in earlier versions, but for D3FO it was deprecated and replaced with `setTimeOutEx` instead. Unfortunately, this does not have the `idle` optional parameter. Not sure if it can be used to achieve the same effect, but might be wort checking out. – FH-Inway Jul 11 '19 at 10:18
  • 2
    I've had issues with `setTimeOutEx` personally. You might consider using the `TimerControl` and dynamically adding it to forms via the `FormRun` class, but it's only increments of 1 second (no `ms`). If you want `ms` increments, you should just copy the `TimerControlJS` and `TimerControlHtml` to make your own and edit the javascript to allow more granular control. Perhaps adding other useful properties too that you could reference from the control. – Alex Kwitny Jul 11 '19 at 17:07
  • @AlexKwitny I am using the Timer Control, I believe seconds are enough granularity for me. The question I have is not the timer to use, but how to track user interaction (clicks/scrolls/selectionchanged etc) without subscribing to 50+ events on the form, which is my current design. As it stands whenever an event fires it calls the TimerControl.interval(IntervalInMinutes * 60) to reset the clock. How can I reduce subscribing to all the form's events and instead find one "catch-all" event to reset the clock – rjv Jul 11 '19 at 17:16

0 Answers0