1

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];

    system.debug('---orderid---'+orderId);
 }
 Public Pagereference go(){
    PageReference pageRef = new PageReference('/apex/OrderTrackingClass?id={!orderId}');
    pageRef.setRedirect(true);
   // 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

www.somesite/apex/OrderTrackingClass?id=+%7B%21orderId%7D

I guess my syntax for pageRef is incorrect.

Please guide me. Thanks

0
2

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);
0

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.