- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2016 10:56 AM
Hi all
Has anyone added a timer to a catalog item so that if the user does not complete the form within a permitted timeframe the page is either closed or a variable is cleared ?
This is not a Workflow issue as the item has not been submitted
I have been tasked with reserving a loan phone which i can do, but if the user closes the form or it crashes I want to clear this reservation
The way I plan to do that is a Workflow on the phone table so that when the initial marker is added I start a Workflow and if after xx minutes the values have not changed the values are cleared and the phone is added back to the pool - that works.
My problem is the form. If the user stays in the form I want a way to either take the user back to the catalog or clear the value so they need to rechoose.
I found a reference to a ui macro that has a timer Session Timeout timer , and indeed when I create that Macro and make a ui formatter it works a treat on an existing record and I can set a field value so I know it works
Problem when I add the ui macro to the catalog item I get the label and no counter.
Any ideas are appreciated
UI macro as a formatter
UI macro when added to a catalog item
the UI Macro code
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<tr>
<td data-type="label" choice="0" nowrap="true" class="label label_spacing">
<span class=" label_description" title="" mandatory="false" oclass="">$[SP]</span>
<label dir="">Session Timeout</label>
</td>
<td nowrap="true">
<span id="custom_session_timer"></span>
</td>
</tr>
<script>
addLoadEvent(startSessionTimer);
function startSessionTimer(){
try{
if($('custom_session_timer')){
//Move the update set picker from under the gear icon to the header
timer = new globalTimer(1*60);
test = setInterval(function(){sessionTimer();}, 1000);
}
}catch(e){}
}
var globalTimer = Class.create();
globalTimer.prototype = {
initialize: function(time_input) {
this.time = time_input;
},
getTime: function() {
return this.time;
},
countDown: function(time_input) {
this.time--;
},
getHours: function() {
return parseInt( this.time / 3600 ) % 24
},
getMinutes: function() {
return parseInt( this.time / 60 ) % 60;
},
getSeconds: function () {
return this.time % 60;
}
};
function calcSessionTimer(){
var hr = timer.getHours();
var min = timer.getMinutes();
var sec = timer.getSeconds();
if (timer.getTime() == (60*30 - (60*25))) {
g_form.addInfoMessage("Session will expire in 5 minutes");
}
if (timer.getTime() == 0) {
g_form.setValue('short_description','TEST');
g_form.addErrorMessage("Session has expired, please save your work");
clearInterval(test);
}
if (hr ${AMP}lt; 10){
hr = " " + hr;
}
if (min ${AMP}lt; 10){
min = "0" + min;
}
if (sec ${AMP}lt; 10){
sec = "0" + sec;
}
timer.countDown();
return hr + ":" + min + ":" + sec;
}
function sessionTimer(){
document.getElementById("custom_session_timer").innerHTML = calcSessionTimer();
}
</script>
</j:jelly>
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 03:59 AM
This as a onLoad script in the variable set works nicely
function onLoad() {
timerFunction();
}
function timerFunction() {
var varWarn1 = setTimeout(alertFunc1, 900000);
var varWarn2 = setTimeout(alertFunc2, 1500000);
var varClear = setTimeout(clearFunc,1800000);
}
function alertFunc1() {
g_form.addErrorMessage('Failure to complete this request within the next 15 minutes will result in your phone choices being cleared');
}
function alertFunc2() {
g_form.addErrorMessage('Failure to complete this request within the next 5 minutes will result in your phone choices being cleared');
}
function clearFunc() {
g_form.setValue('mpl_phone','');
g_form.setValue('mpl_sim','');
timerFunction();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 02:15 AM
Wouldn't it be enough if on submission of the form, you can check if the phone is currently available or not and if it reserved, alert the user and reset the choice ?
I know this isn't the best user experience as the user gets alert only submission, but I am just thinking if the timer is really needed here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 02:43 AM
Hi Kalai
As the user indicates if the phone is to have a SIM or be SIM free, the available phone choices are there.
The user choses said phone and that point the phone is "reserved"
As the form is submitted the WF will then move that from a reservation to a confirmed booking
As soon as the phone is reserved, it is removed from the list of choices so no one else can reserve / book it.
The number of phones in the loan pool is to be limited so someone having it assigned and not completing the form may cause some issues. Setting of a WF on the phone to reset the lock after 30 mins works and puts the phone into the pool. This is great if the users browser crashed and they started again or they just closed down the catalog item and did not release the phone.
I am just trying to do something so if the user has stayed on the Catalog Item but not finished it within the reasonable time frame I close the catalog item or clear the entry. I am trying to avoid the following scenario
User A starts for and selects / reserves phone X
20 mins pass and user B tries to select and phone and there are none and is asked to check again later.
30 mins pass and the WF clears phone X and it is back in the pool
40 mins pass and user B again requests a loan phone, and this time reserves phone X.
41 mins pass and user B now completes their request and the WF confirms phone X for user B
45 mins after starting, User A clicks on submit thinking the have phone X
The WF cannot allocate phone X as it is now processed elsewhere
ideally @ 30 mins to User A I want a message to appear and clear the value, or simply to return User A to the catalog.
There was talk of clearing after a few hours, but that was pointed out that at certain times this delay is too long.
Annoying as the original design as the phone allocated by the ServiceDesk which made it a lot easier until I said "How do we handle the scenario where a user wnats a phone and there are none"
This revised process is added as the form indicates if you do not see any phones in the choice list then there are no available phones to have.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 03:59 AM
This as a onLoad script in the variable set works nicely
function onLoad() {
timerFunction();
}
function timerFunction() {
var varWarn1 = setTimeout(alertFunc1, 900000);
var varWarn2 = setTimeout(alertFunc2, 1500000);
var varClear = setTimeout(clearFunc,1800000);
}
function alertFunc1() {
g_form.addErrorMessage('Failure to complete this request within the next 15 minutes will result in your phone choices being cleared');
}
function alertFunc2() {
g_form.addErrorMessage('Failure to complete this request within the next 5 minutes will result in your phone choices being cleared');
}
function clearFunc() {
g_form.setValue('mpl_phone','');
g_form.setValue('mpl_sim','');
timerFunction();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2018 06:04 AM
I am looking for the same thing but from the portal UI for a catalog item.
The reason is...
We have some catalog items that take a long time to fill out. We have a session idle timeout of 30 minutes. Sitting on a form and typing text doesn't keep you alive. We are finding users work hard on filling out a form only to find upon save, their session timed out a while back and nothing is saved. I need a way to start the timer on the portal UI catalog item submission GUI and when it gets down to 5 minutes display some sort of error telling them to hurry and save. We've all seen this type of warning on web apps. I know my bank web site will throw up a message if I sit idle too long.