0

I have created a Visualforce Page to redirect users to Task's record type selection screen.The user selects a record type then the corresponding page layout opens where the user fills the data and once he clicks on Save, the page should redirect user back to the record type selection screen.

I am able to create the Task but once task is created i am redirected to the home screen.I need to redirect back to the record type selection page

Below is my VF page:

<apex:page controller="testctlr">
  <apex:form>
  <apex:commandButton value="Create Task" action="{!taskcreate}" />
  </apex:form>
</apex:page>

Below is its controller:

public class testctlr{

   public Pagereference taskcreate(){
        return new PageReference('/setup/ui/recordtypeselect.jsp?ent=Task&nooverride=1&save_new_url=%2F00T%2Fe');
   }
}
  • You can redirect to a previous page by using this: PageReference returnPage = new PageReference(ApexPages.currentPage().getParameters().get('retURL')); Of course the current url must contain the parameter 'retUrl'. – Martin Lezer Jan 5 '17 at 13:03
  • @MartinLeze thanks for your reply.I am redirecting my VF page to the standard Task creation page.What should i sepcify in my retURL parameter to redirect it to the task record type selection page?I am trying to figure that out – Abhijeet Jan 5 '17 at 13:27
  • Did you try this? return new PageReference('/01V/e'); – Martin Lezer Jan 5 '17 at 13:30
  • Yes I did.It still redirected me to the home screen – Abhijeet Jan 5 '17 at 13:33
1

I tested this and it worked:

public Pagereference taskcreate(){
        PageReference pageRef = new PageReference('/01V/e');
        pageRef.setRedirect(true);
        return pageRef;
}

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.