We are using lightning experience - servivce console. I am using following code to redirect the page flow to an error page for certain profiles.

I can see in the debug logs that the PageReference is getting correctly set to the error page , but the page redirection does not work

Profile[] profileName = [SELECT Name FROM Profile WHERE Id = :Userinfo.getProfileId() ];
if(profileName[0].Name!='Profile 1')

redirect method

 public PageReference redirectByProfile()

        PageReference pageRef ;
        return pageRef;

debug logs

[559]|DEBUG|pageRef++++System.PageReference[/apex/vferrorpage] 09:23:29.0 (166664283)|SYSTEM_METHOD_EXIT|[559]|System.debug(ANY) 09:23:29.0 (166669547)|STATEMENT_EXECUTE|[560] 09:23:29.0 (166675865)|METHOD_EXIT|[117]|01pq0000000d5sC|CaseDetailsPDFController.redirectByProfile()

1 Answer 1


You're throwing away the return value of redirectByProfile() when you call it in your first snippet. You have to return the PageReference as the result of a Visualforce action method in order for a redirect to take place.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .