Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

How to use salesforce PageReference to redirect after a new record insert?

Asked by Aalap Prabhakaran Apr 18, 2023 1.3K views 1 answer
Share

About this question

I want to redirect the user to a custom vf detail page when they create a new Service Order from my custom page order page (force_NewOrder).

I have created a extension which should save and redirect the user but I am given a generic error:

Error: Error occurred while loading a Visualforce page.

VF (force_NewOrder)
 public force_NewOrderLogic(ApexPages.StandardController controller) { } Service_Order__c order; public PageReference save() { insert order; PageReference orderPage = new PageReference('/force_OrderDetail?id=' + order.id); orderPage.setRedirect(true); return orderPage; } }

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.