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')
{
redirectByProfile();
}
redirect method
public PageReference redirectByProfile()
{
PageReference pageRef ;
pageRef=Page.vfErrorPage;
pageRef.setRedirect(true);
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()