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
GeniuanGeniuan 

actionfunction save not saving

Hi, I'm creating this VF page using inlineEdit. After saving I need it to go back to the VF page so I'm using the actionfunction save instead the save button. Now something is not good because sometimes the information is saved but most of them it's not. Usually it saves the first time the page is loaded, then, it shows like the change is done but doing refresh shows that it wasn't done because the old data comes back.


<apex:page standardController="Contact" sidebar="false" showHeader="false">
<style type="text/css">
    .cols {text-align:center;}
    .col75{width:75%;text-align:left;}
    .col50c{width:50%;text-align:center;}
    .col50{width:50%;text-align:left;}
    .col25{width:25%;text-align:center;}
    .col25g{width:25%;text-align:center;background:#dddddd;}
    .rowsl {text-align:left;font-weight:bold}
    .rowsc {text-align:center;}
</style>
<apex:form >
<apex:pageblock title="" mode="inlineEdit">
      <apex:pageBlockButtons >
                <apex:actionFunction name="saveActionFunc" action="{!save}" oncomplete="redirectBack()"/>
                <apex:commandButton onclick="saveActionFunc();" id="saveButton" value="Save" style="display: none;"/>
      </apex:pageBlockButtons>
      <apex:pageBlockSection title="Tittle 1" columns="1">
<apex:panelGrid columns="3" rowClasses="rowsl,rowsc" id="box1" border="1" frame="below" rules="cols" width="100%" bgcolor="#ffffff">
<apex:outputText value="Names"/>
<apex:outputText value="Partner"/>
<apex:outputText value="Address"/>
<apex:outputfield value="{!contact.Ref_Name__c}">
<apex:inlineEditSupport showOnEdit="saveButton" hideOnEdit="" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit()"/></apex:outputField>
<apex:outputfield value="{!contact.Ref_Name_1__c}"/>
<apex:outputfield value="{!contact.Ref_Name_Direccion_1__c}"/>
 </apex:panelGrid>
      </apex:pageBlockSection>
    </apex:pageBlock>
  </apex:form>
</apex:page>

Any suggestion?

Tejpal KumawatTejpal Kumawat
Hello Geniuan,

Please Use This Snippt also in your code :

<apex:outputPanel id="JSPanel" >
        <script>
            function redirectBack() {
                    window.top.location = '/{!Contact.Id}';
            }
        </script>
    </apex:outputPanel>


and also add reRender="JSPanel"

Thanks
Tejpal
GeniuanGeniuan
Hello Tejpal,

Thanks, here is the new VF. This VF page is embeded into the Standard Contact layout. It looks like reRender="JSPanel" is not needed because the actionfunction calls redirectBack() oncomplete. But I tried also including it.

Adding reRender="JSPanel" to the actionfunction reloads the whole contact page (which is ok). Adding reRender="JSPanel" to the commandbutton loads the whole contact page into the VF container, including heading and sidebar (which is wrong), so I let it in the actionfunction.

Any way it is still not saving.

Any other suggestion?

<apex:page standardController="Contact" sidebar="false" showHeader="false">
<style type="text/css">
    .cols {text-align:center;}
    .col75{width:75%;text-align:left;}
    .col50c{width:50%;text-align:center;}
    .col50{width:50%;text-align:left;}
    .col25{width:25%;text-align:center;}
    .col25g{width:25%;text-align:center;background:#dddddd;}
    .rowsl {text-align:left;font-weight:bold}
    .rowsc {text-align:center;}
</style>
<apex:outputPanel id="JSPanel" >
        <script>
            function redirectBack() {
                    window.top.location = '/{!Contact.Id}';
            }
        </script>
</apex:outputPanel>
<apex:form >
<apex:pageblock title="" mode="inlineEdit">
      <apex:pageBlockButtons >
                <apex:actionFunction name="saveActionFunc" action="{!save}" oncomplete="redirectBack()" reRender="JSPanel"/>
                <apex:commandButton onclick="saveActionFunc();" id="saveButton" value="Save" style="display: none;"/>
      </apex:pageBlockButtons>
      <apex:pageBlockSection title="Tittle 1" columns="1">
<apex:panelGrid columns="3" rowClasses="rowsl,rowsc" id="box1" border="1" frame="below" rules="cols" width="100%" bgcolor="#ffffff">
<apex:outputText value="Names"/>
<apex:outputText value="Partner"/>
<apex:outputText value="Address"/>
<apex:outputfield value="{!contact.Ref_Name__c}">
<apex:inlineEditSupport showOnEdit="saveButton" hideOnEdit="" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit()"/></apex:outputField>
<apex:outputfield value="{!contact.Ref_Name_1__c}"/>
<apex:outputfield value="{!contact.Ref_Name_Direccion_1__c}"/>
 </apex:panelGrid>
      </apex:pageBlockSection>
    </apex:pageBlock>
  </apex:form>
</apex:page>