You need to sign in to do that
Don't have an account?
Redirected to Edit Mode even after saving the record from Edit mode
Hi,
We have an object called Discussions, When I'm trying to edit a record and save it, I'm again taken back to Edit mode but the data is getting saved.
Actually We have a VF page which use Standard Controller and Extension, this page has Edit button when we click on Edit button it takes to a Edit Page where we edit and save that reflects back on Discussion record in the backend. But when we edit the same record in salesforce standard page and click save it is again taken back to edit mode.
<apex:page showHeader="false" standardStylesheets="true" sidebar="false" docType="html" standardController="Discussion__c" extensions="WSEWDiscussionEditController" action="{!IF(LEN($Site.Domain)>0,'',URLFOR($Action.Discussion__c.Edit, Id, null,true))}"> <apex:composition template="MyWSETemplate"> <apex:define name="header">Discussions</apex:define> <apex:define name="breadcrumb"> Create / Edit Discussion </apex:define> <apex:define name="body"> <link href="{!URLFOR($Resource.MyWSEAssets, 'css/chatterCustomFollowers.css')}" rel="stylesheet"/> <apex:form id="createDiscussion"> <div class="row"> <div class="col-md-4"> <img class="center-block img-responsive" src="{!URLFOR($Resource.MyWSEAssets, 'images/feature_1.jpg')}" alt="discussion" /> <div class="row padding10"> <div class="col-xs-12"> <apex:outputPanel rendered="{!theDiscussion.ownerid == $User.Id}"> <apex:commandButton styleclass="btn btn-primary btn-sm" value="SAVE" action="{!save}"/> </apex:outputPanel> <apex:outputPanel rendered="{!theDiscussion.ownerid == $User.Id}"> <apex:commandButton styleclass="btn btn-primary btn-sm" value="CANCEL" action="{!$Page.MyWSEGroupDiscussion}?id={!theDiscussion.id}"/> </apex:outputPanel> </div> </div> </div>
Save method in Controller
public PageReference save() {
try {
theDiscussion.Related_Interest__c = selectedInterest ;
update theDiscussion;
PageReference viewDiscussionPage = Page.MyWSEGroupDiscussion;
viewDiscussionPage.getParameters().put('Id', theDiscussion.id);
return viewDiscussionPage;
} catch (Exception e) {
ApexPages.Message exceptionMessage = new ApexPages.Message(ApexPages.Severity.FATAL, e.getMessage());
ApexPages.addMessage(exceptionMessage);
return null;
}
Please help on how to fix it. Thank You.
We have an object called Discussions, When I'm trying to edit a record and save it, I'm again taken back to Edit mode but the data is getting saved.
Actually We have a VF page which use Standard Controller and Extension, this page has Edit button when we click on Edit button it takes to a Edit Page where we edit and save that reflects back on Discussion record in the backend. But when we edit the same record in salesforce standard page and click save it is again taken back to edit mode.
<apex:page showHeader="false" standardStylesheets="true" sidebar="false" docType="html" standardController="Discussion__c" extensions="WSEWDiscussionEditController" action="{!IF(LEN($Site.Domain)>0,'',URLFOR($Action.Discussion__c.Edit, Id, null,true))}"> <apex:composition template="MyWSETemplate"> <apex:define name="header">Discussions</apex:define> <apex:define name="breadcrumb"> Create / Edit Discussion </apex:define> <apex:define name="body"> <link href="{!URLFOR($Resource.MyWSEAssets, 'css/chatterCustomFollowers.css')}" rel="stylesheet"/> <apex:form id="createDiscussion"> <div class="row"> <div class="col-md-4"> <img class="center-block img-responsive" src="{!URLFOR($Resource.MyWSEAssets, 'images/feature_1.jpg')}" alt="discussion" /> <div class="row padding10"> <div class="col-xs-12"> <apex:outputPanel rendered="{!theDiscussion.ownerid == $User.Id}"> <apex:commandButton styleclass="btn btn-primary btn-sm" value="SAVE" action="{!save}"/> </apex:outputPanel> <apex:outputPanel rendered="{!theDiscussion.ownerid == $User.Id}"> <apex:commandButton styleclass="btn btn-primary btn-sm" value="CANCEL" action="{!$Page.MyWSEGroupDiscussion}?id={!theDiscussion.id}"/> </apex:outputPanel> </div> </div> </div>
Save method in Controller
public PageReference save() {
try {
theDiscussion.Related_Interest__c = selectedInterest ;
update theDiscussion;
PageReference viewDiscussionPage = Page.MyWSEGroupDiscussion;
viewDiscussionPage.getParameters().put('Id', theDiscussion.id);
return viewDiscussionPage;
} catch (Exception e) {
ApexPages.Message exceptionMessage = new ApexPages.Message(ApexPages.Severity.FATAL, e.getMessage());
ApexPages.addMessage(exceptionMessage);
return null;
}
Please help on how to fix it. Thank You.
Try to use the following line of code to return to standard view page: Instead of: