Posts Tagged ‘VisualForce

09
Aug
09

Force.com Tip: ‘New’ Button Override to Assign VisualForce Page to Specific Record Type Using Native Apex Code

* Updated 8.14.09 with a link to a similar post by Jeff Douglas and refactored code that is more applicable to a broader audience using Apex PageReference methods rather than the original string concatenation that was used for human (non-Salesforce developer) readability

You’ve probably come across this before…you need to create a custom VisualForce page for a specific Record Type, but overriding the ‘New’ or ‘Edit’ button seems to be an all-or-nothing proposition (i.e. you can do a single VisualForce page and embed the Page Layout using Apex:Detail, but you can’t mix custom pages with standard Page Layouts). We came across this recently at Delivered Innovation, and we want to share our solution with the community. This specific example involves the Saleforce Case object, but can be applied to any Standard or Custom Object.

Use Case: Client has multiple call centers supporting various product lines; support team ‘A’ requires a custom Wizard to rapidly search for and collect details for the Case record that the standard Salesforce search interface cannot provide.

Solution: While you can assign a specific Page Layout to a specific Record Type and embed VisualForce pages in the object Detail view, currently salesforce.com does not support embedded VisualForce Pages in the Edit view of a Page Layout; likewise, salesforce.com does not support custom VisualForce pages for specific Record Types.  The solution is to “intercept” the command to create a new record in an Object before Salesforce processes it, and this is accomplished with a 1-line VisualForce page and a StandardController extension that pulls and analyzes certain URL parameters to enhance the out-of-the-box process routing capabilities of Salesforce.

Continue reading ‘Force.com Tip: ‘New’ Button Override to Assign VisualForce Page to Specific Record Type Using Native Apex Code’




Cloud computing application & service design by Delivered Innovation

Subscribe to Delivered Innovation with RSS  Follow Delivered Innovation on Twitter  Find Delivered Innovation on Facebook