1

I'm using Account edit button override with custom visualforce page. In the visualforce page, it correctly redirects to that particular Account edit page, but the save and cancel button doesnt doesnot working click standard edit layout. Itstays in the same page and doesn't redircts back after saving/cancelling. Here is the page :

<apex:page standardController="Account" action="{!IF(
 (Account.RecordType.Name=='Engagement Plan'|| Account.RecordType.Name=='Strategic Initiative')
, URLFOR($Action.Account.Edit,Account.Id,null,true)
, '/apex/test_kk?id=Account.Id'
)}" >
<apex:variable value="{!Account.RecordType.Name}" var="recTypeName"/> 
</apex:page>

Can anyone help me what i'm missing here? thanks!

1 Answer 1

2

You need to include the appropriate URL params that tell the standard Save (saveURL) and Cancel (retURL) buttons where to go. These should go in your URLFOR function where the null currently is:

URLFOR($Action.Account.Edit,Account.Id,['retURL'=cancelDestination, 'saveURL'=saveDestination],true)

7
  • thanks @RenegadeCoder, can you be more specific where i need to add this params?
    – user59759
    Jan 13, 2015 at 15:04
  • 1
    Yes, I just doubled-checked the documentation and edited my answer Jan 13, 2015 at 15:07
  • thanks @RenegadeCoder a lot ! i'm updating my code accordingly
    – user59759
    Jan 13, 2015 at 15:09
  • 1
    I might have goofed on the single quotes... I see some examples online that seem to show quotes around the param values rather than the param names, so please let me know which is correct and I'll update my answer again Jan 13, 2015 at 15:20
  • 1
    Yes, that's a common issue with standard page controllers: it only queries into context the fields that are being used on the page. You can get around this by introducing another apex:variable that references the field you need. You may also need to embed another nested URLFOR as the value for the retURL, because I've definitely run into an issue requiring that before (sorry, I don't remember the exact scenario that required it) Jan 13, 2015 at 16:30

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.