I need to create a visualforce page that automatically creates a case and an event about the case creation. Once a user lands on that page, which has one parameter identifying the account, if the account is found the case is created and the user is redirected to the case edit page, otherwise the user is redirected to the new case page. This is all done by putting a method on the action attribute of the page tag. The method returns a PageReference.

To do this, is it better to use a standard controller (Case's one) with an extension or a custom controller (my choice for now)?

2 Answers 2


A benefit of creating a controller extension-based page is that the page can be used in place of the default pages for the standard New/Edit/View actions (via the "Buttons, Links, and Actions" setup). The page then fits cleanly into the normal action flow of the platform.

(You may of course in a controller extension make use of any of the standard controller functionality if that helps.)

But for your page, that may not make sense. Or perhaps even your page should extend the standard Account controller...

  • I think I'm going for the custom controller. How bad is it that I make 2 redirects like this: new PageReference('/'+openedCase.Id+'/e?retURL=%2F'+openedCase.Id); ? That's the only reason why I thought about the extension.
    – tony danza
    Mar 31, 2014 at 9:47
  • @tonydanza Not sure that the retURL is needed. But whether it is or not, jumping between pages is pretty normal and if there is an extra redirect its only a few hundred milliseconds and that is a small price to pay for a simple solution.
    – Keith C
    Mar 31, 2014 at 9:53

You have to use custom controller.

For a page with a single record, accessing standard data and behavior of your object you would use standard controller.If you want to use completely custom functionality and don't really need most of the standard object behaviors, custom controller is a good option, but bear in mind, any standard actions you want to use will have to be implemented in your custom class.There are 3 types of controller (actually 4 but two are variants of the same, standard controller):

Standard - these are provided by the platform so you can produce Visualforce pages without writing code. You'd use these when you have a singe object to manipulate. It provides a save method to allow you to persist changes. There's a variant of this that handles a collection of records - the standard list controller.
Custom controller - this is written in Apex and requires you to write code for any behaviour you ned. You'd use these when your page isn't dealing with a main object - e.g. A launch pad that can take you to a number of different sub pages.
Extension controller. This provides additional functionality to a controller - either a standard controller (e.g to manipulate child records along with a parent) or a custom controller (this is often overlooked and is a way to provide common functionality across a number of pages).
  • could you explain why?
    – tony danza
    Mar 31, 2014 at 9:27
  • edited the answer Mar 31, 2014 at 9:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .