[SalesForce] override standard edit button based on recordtype

I have a requirement to show different edit layout, based on recordtype, using standard edit button override. I'm trying to create a visualforce page and assign it to the edit button, refrering this question . here what i've tried so far :

<apex:page standardController="Abv_Core_KAM_Engagement_Plan__c"  action="{!URLFOR(CASE(Abv_Core_KAM_Engagement_Plan__c.RecordType.Name, 'Abv_Core_KAM_Engagement_Plan', '$Action.Abv_Core_KAM_Engagement_Plan__c.Edit,Id' ,'Abv_Core_KAM_Strategic_Initiative','$Action.Abv_Core_KAM_Engagement_Plan__c.Edit,Id','$Action.Abv_Core_KAM_Engagement_Plan__c.Edit,Id'))}" >
<apex:variable value="{!Abv_Core_KAM_Engagement_Plan__c.RecordType.Name}" var="recTypeName"/> 

which errors out

Error: Field $Action.Abv_Core_KAM_Engagement_Plan__c.Edit,Id does not exist. Check spelling.

please suggest any alternatives. thanks !

Best Answer

I think it's the way that you're attempting to nest inside that URLFOR. Try restructuring it so that the Id param is outside the CASE (since it's gonna be the same no matter what), and also don't use quotes around those $Action references. maybe like this (whitespaced for readability)

<apex:page standardController="Abv_Core_KAM_Engagement_Plan__c"  action="{!URLFOR(
     CASE(Abv_Core_KAM_Engagement_Plan__c.RecordType.Name, 
            'Abv_Core_KAM_Engagement_Plan',      $Action.Abv_Core_KAM_Engagement_Plan__c.Edit,
            'Abv_Core_KAM_Strategic_Initiative', $Action.Abv_Core_KAM_Engagement_Plan__c.Edit,
            $Action.Abv_Core_KAM_Engagement_Plan__c.Edit
     ), Abv_Core_KAM_Engagement_Plan__c.Id) }" >

Although, I'm a bit confused because it looks like you're sending it to the same place every time...