[SalesForce] How to Override Edit button for Custom Visualforce page based on RecordID

I have Order form,where there are 3 types of Orders(OrderScan,OrderFill,OrderGet) for each of these i have created Visualforce Page for new Orders(By Overriding New button).Based on these Record types i am redirecting to perticular VF page.

Now i am facing a problem for overriding Edit Button.I have also created 3 VF page for Editing now i should redirect to perticular Edit VF page based on RecordID.How can i do this..?Please help

Thanks in Advance

Best Answer

You could achieve this by using the action propriety of apex:page

Create a new Visualforce page with only this line

<apex:page standardController="Order__c" action="{!URLFOR(CASE(Order__c.RecordType.Name, 'OrderScan', '/apex/vfp1' ,'OrderFill','/apex/vfp2', '/apex/vfp3'))}" >
    <apex:variable value="{!Order__c.RecordType.Name}" var="recTypeName"/>
</apex:page>

override your edit button with this new page.

Don't forget to change the condition and the urls and to add your standard controller (SObject you want to override the Edit button for it) :)

Related Topic