You need to sign in to do that
Don't have an account?

Javascript Owner Change prevention
Hi,
I have a javascript which gets the next case assigned to user who is logged in. If the case owner is a queue, by clicking the get next case, the case is assigned to that user. What I want is to prevent the user to change the owner from queue to him/her if the condition says the user is out of office = True. Here is my code. I don't how to insert the ischange(owner) function in javascript.
Can anyone help please?
I have a javascript which gets the next case assigned to user who is logged in. If the case owner is a queue, by clicking the get next case, the case is assigned to that user. What I want is to prevent the user to change the owner from queue to him/her if the condition says the user is out of office = True. Here is my code. I don't how to insert the ischange(owner) function in javascript.
{!REQUIRESCRIPT("/soap/ajax/18.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/18.0/apex.js")} {!REQUIRESCRIPT("/xdomain/xdomain.js")} {!REQUIRESCRIPT("/support/console/30.0/integration.js")} var id = sforce.apex.execute("RetrieveNextUtils","retrieveNextCase",{userId:""}); // Prevent the user to change the owner from queue to him/her if the condition says the user is out of office = True// if ( '{!Case.Agent_Out_of_Office__c}' == true ){ alert ('Next case cannot be assigned because you are marked as out of office.'); } else if (id!='') { var querystringParams = ""; if (window.location.href.indexOf("isdtp=mn")!=-1) { querystringParams = "?isdtp=mn"; } else if (window.location.href.indexOf("isdtp=vw")!=-1) { querystringParams = "?isdtp=vw"; } //We have successfully retrieved a case if (sforce.console.isInConsole()) { sforce.console.openPrimaryTab(null, '/'+id + querystringParams, true, null, null, null); } else { navigateToUrl('/'+id + querystringParams); } } else { alert('No cases are available at this time.'); }
Can anyone help please?
We should be executing "RetrieveNextUtils.retrieveNextCase" only if not out of office.
Hope this helps! If yes, then mark it as solution.
All Answers
You need to use global variables to make this check on user object.
Hope this helps!
Thanks,
Sumit
I tried with you code. It is throwing validation error first before executing the piece of code. Any suggestion. Here is my code.
We should be executing "RetrieveNextUtils.retrieveNextCase" only if not out of office.
Hope this helps! If yes, then mark it as solution.