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
gopsgops 

PageReference Error in service cloud console - Error Pop up

Hi All,

 

I need to implement a custom button to create a new case and redirect user to edit page of newly created case. This should respect service cloud console. A use case is CSR users can click new case and do so many things before saving the case. So the actual creation time will not be captured if we go with the standard new case. The users may feel the case is not valid and may opt to cancel the case in such scenario, user should be asked for confirmation before canceling the case.

 

For this I created new custom button 'Create and Edit'. This button invokes a visualforce page 'NewCaseCreateEdit'. This VF page is tied to 'NewCaseCreateEditController'.

The VF page calls 'doOnload' controller method. This method

1. Insert a new case

2. Construct return pagereference value and return it

 

This works perfectly in standard Salesforce. However in Service cloud console, a wired Error pop up opens when the user is being redirected to the edit page of the case. The pop up says 'Unknown Error' which has made troubleshooting even more difficult. The debug logs are fine and dont show any error or exception.


Below is the VF and apex code. Please let me know if such a functionality is feasible with service cloud console.

 

Apex Code

public class NewCaseCreateEditController
{
    private ApexPages.StandardController controller;
    
    //==================================================
    // CONSTRUCTOR  
    //==================================================
    public NewCaseCreateEditController(ApexPages.StandardController controller) {
      this.controller = controller;
      
    }
    
    public pageReference doOnload()
    {        
        PageReference            returnValue = null;
        Case                     newCase     = null;
        String                   personAccountID = '';        
        personAccountID = Apexpages.CurrentPage().getParameters().get('parentAcc');
        system.debug('person Account -->'+ personAccountID );
        newCase = new Case(
           Origin = 'Phone'
           ,Status = 'New'           
        );
        
        if(personAccountID!='')
        {
         
             List<Account> personAccounLst = [Select a.PersonContactId From Account a where a.IsPersonAccount = true and a.Id =: personAccountID limit 1];   
             if(personAccounLst.size()==1)
             {
                 newcase.ContactId = personAccounLst[0].PersonContactId;     
             }
        }
         
         
        Savepoint sp = null;
        try{
            sp = Database.setSavepoint();            
            insert newCase;
            returnValue = new ApexPages.StandardController(newCase).edit();            
            returnValue.getParameters().put('isdtp','vw'); //Console Agent                     
            returnValue.getParameters().put('retURL','/'+newCase.id );
            returnValue.getParameters().put('cancelURL',System.Page.AbandonPhoneCase.getUrl()
                    + '?id='
                    + newCase.id);            
            system.debug('Return URL-->'+returnValue);
        }catch(Exception e){
            if(sp != null){
                Database.rollback(sp);
            }
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'An occurred while opening new case',''));
            ErrorUtils.handleError(e);
        }
        return returnValue;
    }
}

 

VF page

<apex:page standardController="Case" extensions="NewCaseCreateEditController" action="{!doOnload}" sidebar="false" showHeader="false">
    <div style="display:none;" id="errorTitle">Insufficient Privileges</div>    
</apex:page>

 

 

Please let me know if you need more details.

 

Thanks,

Gopal

 

 

 

acousticacoustic
I get the same error when try to click the standard "New Case" button
acousticacoustic
I solved my problem with standard button by giving the profile a default case record type (before it was no default). Other Salesforce apps don't care if you have it set, but Console seems to require it. Maybe that will help with your case too