1

I would like to redirect users from my custom visualforce 'New Record' page to custom detail page passing an ID parameter while doing so. The current behavior, after creating the record the user will be shown the normal salesforce record detail page.

I have constructed some code for this but I am not sure if its correct, the first issue I get is with the extension:

Expression must be a list type: SOBJECT:Service_Order__c at line 6 column 80

UPDATE: Now page leads to the following issue

Error: Error occurred while loading a Visualforce page.


VF:

<apex:page showHeader="false" title="New Order" standardController="Service_Order__c" extensions="force_NewOrderLogic">
...
<apex:commandButton value="Create Order" action="{!save}" styleClass="btn btn-success" rerender="error,styledError,unstyledError"/> 

Apex (updated):

public class force_NewOrderLogic {

    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;
    }
}
1

You have one order record, so you don't need to use an index to retrieve the id. Just change it to order.id. You would use the [0] on a list of orders not a single order. Also, create a new order for inserting: Service_Order__c order = new Service_Order__c.

  • That fixed the issue! However I am now lead to a generic error when saving the record. Please see updated post. – Deployment Failure Oct 7 '14 at 14:46
  • exntensions="force_NewOrderLogic"; extension is spelled wrong – Jenny B Oct 7 '14 at 14:50
  • Good catch! this was only in the code above (I have updated it now), the force page has the correct line – Deployment Failure Oct 7 '14 at 14:51
  • Can you open a new question with your full page/extension code? – Jenny B Oct 7 '14 at 14:59

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.