Skip to Content
Author's profile photo Former Member

Auto Cancel any transaction if not finished in time on WebUI

The agents/users tend to stay over a transaction for a long period of time and do not let anyone else update it. When they try to come back to their work and edit/save it, it gets lost/incomplete due to session timeout. Wouldn’t it be nice to have warning message ir-respective of the window you are on and a functionality to Auto click the ‘CANCEL’ button if the transaction is not finished in a stipulated time. Read on and you’ll find how this can be achieved.

This functionality can achieved by doing a little bit of coding in the htm page of ‘CRM_UI_FRAME/WorkAreaViewSet’

a. Set the value of the warning and cancellation time – at which the warning message should appear and CANCEL clicked. Be it a custom table or variant, your choice.

b. Fetch this value in the htm page.

c. Start a timer using JS. Refer my previous post for the timer : Timeout / Countdown Timer on CRM WebUI

d. Code Snippets :-


<script>
var warn = <%= warn %>;
var canc = <%= canc %>;
var sr_time = 1 ;
var can_pressed = 0 ;
function press_can() {
      can = document.getElementById('C18_W59_V61_#Exit#_CANCEL');
      return htmlbSL(can,2,'C18_W59_V61_#Exit#_CANCEL:\x23Exit\x23_CANCEL','0');
}
function tempAlert(msg,duration)
{
var el = document.createElement("div");
el.setAttribute("style","position:absolute;top:20%;left:45%;background-color:yellow;");
el.innerHTML = msg;
setTimeout(function(){
  el.parentNode.removeChild(el);
},duration);
document.body.appendChild(el);
}
if (sr_time == warn )
    {
        var myWindow = window.open("", "", "width=200, height=100");   // Opens a new window
        myWindow.document.write("<p>Active Transaction Idle Timeout Warning</p>");         // Some text in the new window
        myWindow.focus();
        var msgg1 = "Session Idle for too long. Any active SR will be cancelled in ";
        var msgg2 = <%= canc - warn %> ;
        var msgg3 = " seconds, unless saved by user" ;
        var msgg4 = msgg1.concat(msgg2,msgg3) ;
        var msgtime = msgg2 * 1000 ;
        tempAlert(msgg4,10000);
    }
if (sr_time == canc )
    {
      press_can() ;
      can_pressed = 1 ;
    }
</script>

This is not the complete code but a code snippet. Use the Timer code in combination to this code. We have to initialise the value of ‘sr_time’ whenever the page loads and ‘can_pressed’ whenever ‘CANCEL’  button is pressed.

‘C18_W59_V61_#Exit#_CANCEL’ – this will vary. On any active transaction, goto developer tools in the Browser’s menu and click on ‘Select Element’ and select the cancel button.

You are invited to tinker around the code to create your own enhancements.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Cool 🙂