05-08-2018 06:51 AM
I am using beforeunload function and below code works fine if agent accidentally close browser but same code is executing if agent is trying to logout using sign-out button.Does any one have idea how i can skip this logic if agent try to logout in normal way.
$(window).on('beforeunload', function () {
return "You cant close the browser without going to NOT_READY and then LOGOUT!";
rc = { id: '28' };
user.logout(rc, {
success: makeCallSuccess,
error: makeCallError
});
});
Any help is really appreciated.
05-08-2018 10:36 AM
Hi,
Maybe you can do an agent state check within that function? Depending on when that function is called, that the agent state is LOGOUT?
Thanx,
Denise
05-09-2018 01:42 PM
Thanks Denise.I tried below code just to check whether we get alert when we click on SIGN-OUT dropdown but no luck.Do you know why?
if (user.getState() == "LOGOUT") {
alert("In LOGOUT");
05-09-2018 01:53 PM
Hi,
The code looks fine. Maybe the agent state isn't actually LOGOUT. I am not sure when the beforeunload function gets called. You should use the browser's developers tool to see what the agent state is in that function.
Thanx,
Denise
05-21-2018 07:59 AM
Hi Denise,
I did try above scenario and when agent click Logout/Sign Out on right top, agentstate is still NOT_REEADY and nothing like 'LogOut' to check condition in my code.Any idea?
05-21-2018 03:10 PM
Hi,
I don't think there is a way then. Checking the state is the only thing I can think of, but it seems from your testing that no matter if you click the X or the logout button, the agent is in NOT_READY state when the beforeunload is called.
Thanx,
Denise
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide