+ Start a Discussion
SkadamSkadam 

URLFOR redirecting to the same page / Doesn’t gets the selected Record type

I have written the following code for VF page and I have overridden opportunity new button with my VF page

 The problem is that when I click new opportunity, I am directed to record type pick list page to select the opportunity record type. When I select the opportunity type and hit continue, I am getting redirected to the same page! After that when I hit continue again, I am getting redirected to the next page correctly.

 

<apex:page standardController="Opportunity">

<script>

window.top.location.replace("{!URLFOR($Action.Opportunity.New, opportunity.id, [saveURL='/apex/oppRedirect', retURL='/'+opportunity.id, cancelURL='/'+opportunity.id], true)}");

</script>

</apex:page>

 

I have look into some posts and added parameters, save=1 and nooverride=1 in URLFOR method  shown below.

window.top.location.replace("{!URLFOR($Action.Opportunity.New, null, [saveURL='/apex/oppRedirect', retURL='/'+opportunity.id, cancelURL='/'+opportunity.id, RecordType='/'+opportunity.RecordTypeId, save=1, nooverride=1], TRUE)}");

 

this did eliminate the repeated twice selection of record type but now it just dose is default  selects the first record type even when I select the other record type.

The thing that I want to achieve is redirect user to a custom VF page and he saves the opportunity  I am unable to fix the problem of getting redirected to the same page when I click continue first time though.

sunny522sunny522
Hi Skadam,
            While redirecting to vf page you can skip record type selection page by clicking the checkbox of "Skip Record Type Selection Page" as shown in image  
below.

.User-added image