3

I am overriding the New button of a custom object using a Visualforce page. Now this vf page's controller does some calculation based on a criteria and assigns a record type to the newly created custom object, save the custom object and redirects the user to the newly created record.

However if the criteria is not met I want to send the user to the standard record type selection page, where they will select a record type and it will redirect them back to this same page where the code will read the selected record type, create a new record and then redirect the users to the new record page.

I am successfully able to redirect the user to the standard record type selection page using this url :

/setup/ui/recordtypeselect.jsp?retURL=%2Fa0G%2Fo&ent=01Ii0000000mXbK

However after selecting the record type I am not able to redirect them back to the vf page with the selected record type id.

I figured I needed the save_new_url parameter or I updated the link to

/setup/ui/recordtypeselect.jsp?retURL=%2Fa0G%2Fo&ent=01Ii0000000mXbK&save_new_url=/apex/MyVfPage

But its still not working. What am I missing here?

  • Could you instead just allow them to select the record type on your visualforce page? – Jenny B Sep 1 '15 at 11:38
  • I can, but that is not what the "requirements" want me to do. They want the user to be redirected to the standard record type selection page. – codeinprogress Sep 1 '15 at 11:46
1

not sure what you see when the redirection happens, but when I try the same in my dev org, it does redirect to the VF page from the record type selection page and the selected record type id comes in as a query string parameter.

here's the url in the record type selection page

https://{mySFDomain}/setup/ui/recordtypeselect.jsp?ent=Case&retURL=%2F500%2Fo&retURL%3D%252F500%252Fo&save_new_url=/apex/hello

and when i select a record type and click continue, i end up with this url

https://{myVFDomain}/apex/hello?RecordType=012900000015G4p&ent=Case&retURL%3D%252F500%252Fo

Note : I have used Case object in my dev org.. and don't think it will behave different for a custom object, so this should work for you as well.

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.