I'm trying to capture orderid from URL and then redirect user to a different visualforce page OrderTrackingClass after finding the orderId Following is what I tried...

public with sharing class redirectOrderPartner{

public String currentRecordId {get;set;}
public orders__c orderId {get;set;}

public redirectOrderPartner(ApexPages.StandardController controller) {

currentRecordId  = ApexPages.CurrentPage().getparameters().get('orderid');

    orderId = [select id from orders__c where name =: currentRecordId limit 1];

 Public Pagereference go(){
    PageReference pageRef = new PageReference('/apex/OrderTrackingClass?id={!orderId}');
   // return pageRef;

and in Visualforce page I addded ...

    <apex:page standardcontroller="orders__c" extensions="redirectOrderPartner" action="{!go}">

The debug logs are showing correct results. But I'm being redirected to


I guess my syntax for pageRef is incorrect.

Please guide me. Thanks


Your syntax is wrong. You don't have to use visualforce syntax in apex for variables:

PageReference pageRef = new PageReference('/apex/OrderTrackingClass?id=' + orderId.id);

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.