0

I am having an issue where I need to override the standard New/Edit/View buttons on Cases with Visualforce pages.  These pages are just re-directs as I need to have 1 Case record type that is replaced by custom VF pages.  All other record types should go to the standard URLs that come up when the standard buttons are clicked.  The issue I am having is that overriding the standard buttons also disables inline editing, which cannot happen.  Does anyone know of a way to allow inline editing when standard buttons are disabled?  I know how to do it on the custom VF pages, but not on the standard pages.  Below is one of the VF pages overriding the View button, but it does not allow inline editing:

VF Page (View Button Override):

<apex:page standardcontroller="Case" extensions="VF_Controller_CaseView" action="{!CaseRedirect}">
    <apex:detail inlineEdit="true" relatedList="true"/>
</apex:page>

Controller:

//Controller to Override Case detail view to allow for Account Services VF pages but maintain standard pgs for all other cases
public with sharing class VF_Controller_CaseView{

public Case c1;

    public VF_Controller_CaseView(ApexPages.StandardController controller){
        this.c1 = (Case)controller.getRecord();
    }


    public PageReference CaseRedirect() {

        Case recType = [SELECT Id, RecordType.Name
                        FROM Case
                        WHERE Id =: c1.Id];

        if(recType.RecordType.Name == 'AcctSvcs'){
            PageReference pageRef = new PageReference('/apex/VF_CaseView?id=' + recType.Id);
            return pageRef;
        }
        else{
            PageReference pageRef2 = new PageReference('/' + recType.Id + '?nooverride=1');
            return pageRef2;
        }
    }
}
1

What if instead of redirecting to a custom VF page that uses apex:detail, you redirect to a URL that suppressed the VF override and shows the default view page?

That's what I did for my case object: My new/view/edit buttons all redirect to a 'Redirect' VF page that does nothing but call an extension method that determines whether to show a VF page or suppress the VF override.

Here is the 'redirect' vf page:

<apex:page standardController="Case" extensions="CaseUniversalControllerExtension" action="{!pageRedirect}">
</apex:page>

The pageRedirect() method that VF page is referencing has the following bits of relevant code:

    map<string, string> pageParameters = ApexPages.currentPage().getParameters();
  //uses info from SF URL to determine which button was clicked
    if(pageParameters.get('Id') == null) detectedMode = 'New';
    else if(pageParameters.get('Id') != null && pageParameters.get('retURL') != null) detectedMode = 'Edit';
    else if(pageParameters.get('Id') != null && pageParameters.get('retURL') == null) detectedMode = 'View';

With the 'mode' determined (view/new/edit), you can determine which VF page you want to redirect to, or you can choose to suppress the VF page and show the default:

here is redirecting to another VF page:

        if(detectedMode == 'New') return new PageReference('/apex/CasePortalUserEdit');
        else if(detectedMode == 'Edit') return new PageReference('/apex/CasePortalUserEdit?id='+pageParameters.get('Id') + '&retURL=/' + pageParameters.get('Id'));
        else if(detectedMode == 'View') return new PageReference('/apex/CasePortalUserView?id='+pageParameters.get('Id') + '&retURL=/' + pageParameters.get('Id'));     

and here is suppressing the VF page:

        if(detectedMode == 'New') return new PageReference('/500/e?ent=Case&nooverride=1&RecordType='+recordTypeID+'&retURL=/500/o');
        else if(detectedMode == 'Edit') return new PageReference('/' + pageParameters.get('Id') + '/e?nooverride=1&RecordType='+recordTypeID+'&retURL=/' + pageParameters.get('Id'));
        else if(detectedMode == 'View') return new PageReference('/' +pageParameters.get('Id') + '?nooverride=1');     

the key parameter for suppressing a VF page is NoOverride=1

  • Thanks, but that didn't change anything. I still don't have inline editing on standard layouts. I think as long as any VF page is overriding a standard edit button, inline editing is disabled, regardless of where the VF page redirects. – J. Neilan Jun 6 '16 at 17:45
  • huh, ok. I know that to add inline editing to VF pages you actually need to add inline editing tags to every input field on the VF page layout.. but you're goal of using the apex:detail component won't allow you to do that. Interesting. – smohyee Jun 7 '16 at 18:29
  • Thanks. I ended up having to not override the standard Edit button, and then doing as you said to use <apex:InlineEditSupport> inside my outputField tags. Not ideal, but at least it works for now. Thanks for the help! – J. Neilan Jun 7 '16 at 18:33
  • Yeah, its the 'long way' to your goal, and they should definitely support inline editing as a general feature as an alternative to making you specify it for each field. Glad you got it working! – smohyee Jun 7 '16 at 19:47
1

Inline editing should still work after overriding the standard view/edit buttons with a VF page controller extension.

In your controller code, just stay on the same page instead of redirecting, and hence have a return null the else block of your code.

/****Controller to Override Case detail view to allow for Account
Services VF pages but maintain standard pgs for all other cases*****/

public with sharing class VF_Controller_CaseView{

public Case c1;

public VF_Controller_CaseView(ApexPages.StandardController controller){
    this.c1 = (Case)controller.getRecord();
}


public PageReference CaseRedirect() {

    Case recType = [SELECT Id, RecordType.Name
                    FROM Case
                    WHERE Id =: c1.Id];

    if(recType.RecordType.Name == 'AcctSvcs'){
        PageReference pageRef = new PageReference('/apex/VF_CaseView?id=' + recType.Id);
        return pageRef;
    }
    else{
        //PageReference pageRef2 = new PageReference('/' + recType.Id + '?nooverride=1');
        //return pageRef2;
         return null; // (this should fix the issue and allow you to edit inline)

    }
}
}
0

I think you may need to add the subject attribute string to your Apex:Detail page.

<apex:detail subject="{!variable_for_Case.Id}" inlineEdit="true" />

See documentation on Apex:Detail.

  • Thanks, but that didn't change anything. I still don't have inline editing on standard layouts. – J. Neilan Jun 6 '16 at 17:44
0

Just to close this thread, I ended up not overriding the standard Edit button and instead instructed users to click into the Case records to edit instead of click on the Edit button in the list view. Not ideal, but losing the ability for inline editing by overriding the standard Edit button was not going to be an option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.