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
MattMet86MattMet86 

PageReference shows within existing VF page instead of redirecting to new page.

My pagereference is being shown within the existing VF page instead of redirecting to a new page. Can someone tell me what i have done wrong? 

Here is the VF page before I click the button:

User-added image

Here is the page after I click the button:
User-added image

Here is the code for that group of buttons:

<apex:pageBlockButtons id="pbb_save" location="bottom" rendered="{!!sessionEditDisable}">
                    <apex:commandButton action="{!saveChangesNewPage}" value="Save Voluntary Info" rendered="{!!serviceSession}" rerender="theForm" status="status" />
                    
                    <apex:commandButton action="{!ScheduleReview}" value="Save,Schedule Review" rendered="{!!serviceSession}" rerender="theForm" status="status" />
                    
                    <apex:commandButton action="{!assignFollowUpTask}" value="Save,Assign Follow-Up Task" rendered="{!!serviceSession}" rerender="theForm" status="status" />

                     <apex:actionStatus id="status">
                        <apex:facet name="start">
                            <div style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; opacity: 0.50; z-index: 1000; background-color: gray;">
                                &nbsp;
                            </div>
                            <div style="position: fixed; left: 0; top: 0; bottom: 0; right: 0; z-index: 1001; margin: 20% 50%">
                                <img src="/img/loading32.gif"/>
                            </div >
                        </apex:facet>
                    </apex:actionStatus>
                    
                </apex:pageBlockButtons>

Here is the code from the extension controller for the scheduleReview button:
public pageReference scheduleReview() {
        
        system.debug('in scheduleReview method'); 
        
        saveChanges();
        recordTypes = [SELECT id FROM RecordType WHERE (Name = 'ScheduleReview' OR Name = 'Schedule Review') AND sObjectType = 'Event' ];
        Employee_Session__c es = [SELECT id,Employee__c,Session_Status__c FROM Employee_Session__c WHERE id = :esId];
        
        PageReference pr;
        pr = new PageReference('/00U/e?');
        pr.getParameters().put('what_id',es.Employee__c);
        pr.getParameters().put('retURL','%2F' + es.Employee__c);
        pr.getParameters().put('RecordType',recordTypes[0].id);
        pr.getParameters().put('ent','Event');
        return pr;
    }

 
Nagendra ChinchinadaNagendra Chinchinada
Hi Matt,

Add   pr.setRedirect(true);​ in controller.
 
public pageReference scheduleReview() {
        
        system.debug('in scheduleReview method'); 
        
        saveChanges();
        recordTypes = [SELECT id FROM RecordType WHERE (Name = 'ScheduleReview' OR Name = 'Schedule Review') AND sObjectType = 'Event' ];
        Employee_Session__c es = [SELECT id,Employee__c,Session_Status__c FROM Employee_Session__c WHERE id = :esId];
        
        PageReference pr;
        pr = new PageReference('/00U/e?');
        pr.getParameters().put('what_id',es.Employee__c);
        pr.getParameters().put('retURL','%2F' + es.Employee__c);
        pr.getParameters().put('RecordType',recordTypes[0].id);
        pr.getParameters().put('ent','Event');

        pr.setRedirect(true);

        return pr;
    }

Let me if it helps you.
Mahesh DMahesh D
Hi Matt

Please follow this code:

Add <apex:pageMessages/> at the top after the <apex:form tag so that we will know if there is any validation error.
<apex:pageMessages/>
<apex:pageBlockButtons id="pbb_save" location="bottom" rendered="{!!sessionEditDisable}">
                    <apex:commandButton action="{!saveChangesNewPage}" value="Save Voluntary Info" rendered="{!!serviceSession}" rerender="theForm" status="status" />
                    
                    <apex:commandButton action="{!ScheduleReview}" value="Save,Schedule Review" rendered="{!!serviceSession}"  status="status" />
                    
                    <apex:commandButton action="{!assignFollowUpTask}" value="Save,Assign Follow-Up Task" rendered="{!!serviceSession}" rerender="theForm" status="status" />

                     <apex:actionStatus id="status">
                        <apex:facet name="start">
                            <div style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; opacity: 0.50; z-index: 1000; background-color: gray;">
                                &nbsp;
                            </div>
                            <div style="position: fixed; left: 0; top: 0; bottom: 0; right: 0; z-index: 1001; margin: 20% 50%">
                                <img src="/img/loading32.gif"/>
                            </div >
                        </apex:facet>
                    </apex:actionStatus>
                    
                </apex:pageBlockButtons>

Controller:
 
public pageReference scheduleReview() {
        
        system.debug('in scheduleReview method'); 
        
        saveChanges();
        recordTypes = [SELECT id FROM RecordType WHERE (Name = 'ScheduleReview' OR Name = 'Schedule Review') AND sObjectType = 'Event' ];
        Employee_Session__c es = [SELECT id,Employee__c,Session_Status__c FROM Employee_Session__c WHERE id = :esId];
        
        PageReference pr;
        pr = new PageReference('/00U/e?');
        pr.getParameters().put('what_id',es.Employee__c);
        pr.getParameters().put('retURL','%2F' + es.Employee__c);
        pr.getParameters().put('RecordType',recordTypes[0].id);
        pr.getParameters().put('ent','Event');
        pr.setRedirect(true);
        return pr;
    }

Also enable the debug and see if there is any error on the page.

Please do let me know if it helps you.

Regards,
Mahesh