function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RstrunkRstrunk 

Change Owner Page for Case

 

 

I have seen that there is no straight forward way to EDIT the change owner page for cases.  I have also saw posts where people say it is possible to make a visualForce page to override it.  Can someone give me an example?  Basically I need to get rid of the "Send Notification Email" checkbox.(we have apex that sends emails).  From what I have found this is a very common problem but not too many resolutions.  

 

Any help would be greatly appreciated.  

 

 

Thanks, 

MTBRiderMTBRider

I couple weeks ago I wrote my own change owner function for Cases.  My  users wanted a quick way to assign a Case to a new owner and they did not want to input a name, click the magnify glass, then click the name.  They wanted to assign a case in as few clicks as possible.  Since in my scenario, only queues and members of queues where allowed to be owners of cases, I created a pop up window that displayed all of the queues in the system and the users that where members of the queues using the <apex:selectRadio> component.   Here are some code snippets of what I did:

 

---- VF page that shows cases in a list.  One of the columns of the list has the following:
<apex:page>
<apex:outputLink onclick="openCaseAssignPopup('{!c.id}','{!c.caseNumber}'); return false;">[ Assign ]</apex:outputLink>

...

<script>
  
   function openCaseAssignPopup(caseId, caseNum) {
       var url='/apex/caseManagementListAssign?id=' + caseId + '&no=' + caseNum;
        var winWidth;
	var winHeight;
			
	winWidth = (window.screen.width/2) - (150 + 30);
	winHeight = (window.screen.height) -  (50);
			            
        newWin=window.open(url, 'CaseAssignment','height=600,width=220,left=' + winWidth +',top=(window.innerHeight + 20)' + winHeight + 
            	',screenX=' + winWidth + ',screenY=' + winHeight + ',resizable=no,scrollbars=yes,toolbar=no,status=no');
            
        if (window.focus) {
           newWin.focus();
        }
                        
        return false;
   }
</script>
</apex:page>

--- VF page for the Case Assignment pop up ----

<apex:page Controller="CaseMgmtListController" title="Assign Case" showHeader="false" sidebar="false">
   <apex:form >
   <apex:panelGrid columns="1" width="100%" cellPadding="20">
	<apex:facet name="header"><h1><center>Assign Case {!$CurrentPage.parameters.no} To:</center></h1></apex:facet>
      <apex:panelGroup layout="inline">
         <apex:selectRadio layout="pageDirection" border="0" value="{!assignSelected}" >   
            <apex:selectOptions value="{!caseAssignments}" id="ca"/>
         </apex:selectRadio>
      </apex:panelGroup>
   </apex:panelGrid>		
   <br/>
   <br/>
   <apex:panelGrid columns="2" width="100%" cellPadding="5" style="vertical-align:middle;text-align: center;">
      <apex:commandButton action="{!assignOk}" id="assignOk" value="Assign" onClick="CloseWindow()"/>
      <apex:commandButton action="{!assignCancel}" id="assignCancel" value="Cancel" onClick="CloseWindow()"/>
   </apex:panelGrid>
   </apex:form>
	
    <script>
      function CloseWindow()
      {
         var winMain=window.opener;
	 if (null==winMain)
	 {
	     winMain=window.parent.opener;
         }
         winMain.closeAssignPopup();
      }
   </script>
</apex:page>

---- Controller code for the assign pop up---

/*
* Used when a user clicks the '[ Assign ]' link on a case.  Builds a radio button list of the queues defined and the members of the queues.   
*  The radio buttons are displayed in a tree-like structure with the Queue name in bold and then corresponding members of the queue below it.
*   The names of the queue members are in italics and are indented a bit
*/
public List<SelectOption> getcaseAssignments() {
	List<SelectOption> assignOptions = new List<SelectOption>();
    	Map<Id, Group> qIdToQName = new Map<Id, Group>([SELECT g.Id, g.Name FROM Group g WHERE g.Type = 'Queue']);
    	List<GroupMember> qMembers = new List<GroupMember>([SELECT m.GroupId, m.UserOrGroupId FROM GroupMember m]);
    	    	
    	List<Id> uIds = new List<Id>();
    	for (GroupMember gm : qMembers) {
    		uIds.add(gm.UserOrGroupId);	
    	}
    	Map<Id, User> uIdToUName = new Map<Id, User>([SELECT u.Id, u.Name FROM User u WHERE u.Id IN :uIds]);
    	if (qIdToQName.size() > 0) {
           for (Id q : qIdToQName.keySet()) {
              assignOptions.add(new SelectOption(q, '<b>' + qIdToQName.get(q).Name + ' Queue</b>'));		//Create a tab option for the queue so the Case can be assign to a queue
              for (GroupMember gm : qMembers) {               //Now search for users that are members of this queue
        	if (gm.GroupId == q) {
        	   if (uIdToUName.containsKey(gm.UserOrGroupId)) {
        		assignOptions.add(new SelectOption(gm.UserOrGroupId, '<i>-  ' + uIdToUName.get(gm.UserOrGroupId).Name+ '</i>'));	//Create a tab option for the User so the Case can be assigned	
        		
        	   }
        	}
            }
         }
       }
       if (assignOptions.size() > 0) {
          for (SelectOption s : assignOptions) {
            s.setEscapeItem(false);	     //This is needed because of the embedded html tags in the assignOptions
          }
       }
        
       return assignOptions;       
    }
/**/

/*
*  getter method for the assign radio buttons
*/
public String getassignSelected() {
   return assignSelected;
}
/**/
 	
/*
*  setter method for the assign radio buttons
*/
public void setassignSelected(String selection) {
   this.assignSelected = selection;
}
/**/
	
/*
*	Assigns a case to the queue or user selected from the radio button list
*	For reasons specific to my implementation, I re-query the case before changing the owner.
*/
public PageReference assignOk() {
   String caseId = ApexPages.currentPage().getParameters().get('id');	//The case ID is passed in the URL
   if (caseId != null) {
      try {
	    Case c = [SELECT OwnerId FROM Case WHERE id = :caseId.trim()];
	    c.OwnerId = assignSelected;
	    update c;
      } catch (System.DmlException e) {
         for (Integer i = 0; i < e.getNumDml(); i++) {
            System.debug(e.getDmlMessage(i));
        }	
     }
   }
   return pageRef.setRedirect(true);       //Also for reasons specific to my implementation, I re-render the screen
}
/**/

 Let me know if this works for your situation.

RstrunkRstrunk

 

 

             KUDOS!!

 

   This isn't exactly what I was looking for but it is very nice!  I'm definitely going to copy this and use it as a reference in the future.  Thanks for sharing.