You need to sign in to do that
Don't have an account?
Semira@gmail.com
Pagereference not redirecting
Hi all,
I have two save method, one just redirects to edit page and the other one save and close and returns to newly created record. However, problem is when I clone the record, the url has Clone = 1 https://atirestoration--fullcopy--c.cs13.visual.force.com/apex/BudgetSheet?clone=1 <--- This one
How do I redirect the record to erase that clone and take the user to edit page. Also, when I do that, Save and close or when I Cancel, page does not return to the main page and shows me a blank page. Please help me out. I'm so lost in this. I'm assuming it is not assigning the controller Id to redirect to the newly created record. How do I solve this?
Here are my two methods:
I have two save method, one just redirects to edit page and the other one save and close and returns to newly created record. However, problem is when I clone the record, the url has Clone = 1 https://atirestoration--fullcopy--c.cs13.visual.force.com/apex/BudgetSheet?clone=1 <--- This one
How do I redirect the record to erase that clone and take the user to edit page. Also, when I do that, Save and close or when I Cancel, page does not return to the main page and shows me a blank page. Please help me out. I'm so lost in this. I'm assuming it is not assigning the controller Id to redirect to the newly created record. How do I solve this?
Here are my two methods:
public PageReference quickSaveBudget(){ PageReference pv; ID OldBudgetID = ExtCon.getID(); ExtCon.save(); try{ // Check if it is Save or Clone. // If CLone the execute clone line item // Then redirect to new budget ID. if(OldBudgetID != ExtCon.getID()){ cloneLineItem(ExtCon.getID(), OldBudgetID); pv = new Pagereference('/'+ExtCon.getID()); pv.setRedirect(true); } Else{ saveLineItem(ExtCon.getID()); getBudgetLineItem(); pv = null; } system.debug('What is the pv returning? '+ pv); }catch(Exception e){ ApexPages.Message emsg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage()); ApexPages.addMessage(emsg); } return pv; } public pageReference saveBudget(){ PageReference pv; ID OldBudgetID = ExtCon.getID(); ExtCon.save(); try{ // Check if it is Save or Clone. // If CLone the execute clone line item // Then redirect to new budget ID. if(OldBudgetID != ExtCon.getID()){ cloneLineItem(ExtCon.getID(), OldBudgetID); } else saveLineItem(ExtCon.getID()); system.debug('What is the pv returning? '+ pv); } catch(exception e){ ApexPages.Message ErrorMsg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage()); ApexPages.addMessage(ErrorMsg); } //pv = ExtCon.view(); pv = new Pagereference('/'+ExtCon.getID()); pv.setRedirect(true); return pv; }
I noticed if it is cloned, it returning new pagereference. However, it is also returning pv at the end. Wouldn't that be blank?