function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
lrw757lrw757 

Pagereference not Redirecting

For some reason, I can't get a custom visualforcepage to redirect. I can't see anything wrong with my code. I've debugged and it's entering the function, it's returning the right url, it just isn't redirecting. The page doesn't even reload. I am calling the function conditionally from a constructor.

 

public pagereference redirect(){
pagereference intermediatePage = Page.PMSprintIntermediatePage;
intermediatePage.setRedirect(true);
return intermediatePage;
}

 

Any thoughts?

Best Answer chosen by Admin (Salesforce Developers) 
lrw757lrw757

Weird. For some reason, it was performing the logic of whether to redirect in one function and calling the actual redirect as a separate function that was giving me the problems. As soon as I combined them in a pagereference and set the other conditions to return null, it worked. Call me confused.

All Answers

lrw757lrw757

fyi I've just tried pulling it out of the constructor and it's still giving me the same response.

lrw757lrw757

Weird. For some reason, it was performing the logic of whether to redirect in one function and calling the actual redirect as a separate function that was giving me the problems. As soon as I combined them in a pagereference and set the other conditions to return null, it worked. Call me confused.

This was selected as the best answer