0

Here when i update the "Record Detail" section ,first section "Account information" validation error is throwing.how to update only the particular section through action region? enter image description here

visualforce page code:

<apex:form > 
<apex:pageBlock title="Enter your Information" >
<apex:pageBlockSection title="Account Information" collapsible="false" >
<apex:inputField value="{!account.Name}" />
<apex:inputField value="{!account.accountnumber}"/>
<apex:inputField value="{!account.Rating}"/>
<apex:inputField value="{!account.industry}"/>
<apex:inputField value="{!account.Active__c}"/>
</apex:pageBlockSection>

<div align="center">
<apex:commandButton action="{!saveAndCongrat}" value="Save" />
</div>

</apex:pageBlock>


<apex:pageblock title="Record Details" >
<apex:pageblockSection title="Recent Record Details" collapsible="false">

<apex:pageblockTable value="{!acc}" var="a">
<apex:inlineEditSupport showOnEdit="update, cancelButton" hideOnEdit="editButton" event="ondblclick" 
changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
<apex:column headerValue="Name" >
 <apex:outputField value="{!a.name}"/>
</apex:column>
<apex:column headerValue="AccountNumber">
  <apex:outputField value="{!a.accountnumber}" />
</apex:column>

<apex:column headerValue="Rating">
 <apex:outputField value="{!a.rating}"/>
 </apex:column>

<apex:column headerValue="Industry">
 <apex:outputField value="{!a.industry}"/>
 </apex:column>

<apex:column headerValue="Active">
 <apex:outputField value="{!a.Active__c}"/>
 </apex:column>

</apex:pageblocktable>

 <apex:commandButton action="{!quickUpdat}" value="UpdateRecord" />
</apex:pageblockSection>   
</apex:pageblock>
</apex:form>   
</apex:page>

Apex code:

public with sharing class saveAndRedirect{
  Account request;
  private Apexpages.standardcontroller controller;
  public saveAndRedirect(Apexpages.standardcontroller controller){
  this.controller = controller;
   }
    public pagereference saveAndCongrat(){
    controller.save();
    pagereference ref = page.Account_custom;
    ref.setRedirect(true);
    return ref;
    }
   private List<Account> acc;
   public String message{get;set;} 
   public List<Account> getacc()
   {
     acc = [select  id,name,accountnumber,rating,industry,Active__c from account ORDER BY id DESC LIMIT 5];
     return acc;
   } 
    public PageReference quickUpdat(){
    try{
    update acc;
    return ApexPages.CurrentPage();
    }catch(Exception e){
    message='Data Base error during saving...';
    ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.ERROR, message));
    return null; }}}
1
  • Add rerender to your appropriate command button's
    – Raul
    Jun 27, 2017 at 7:30

1 Answer 1

1

You can use the rerender attribute as you can see here.

You just have to specify an id to the section that you want to update on the button click. Here's the "Record details" pageBlock. Like this:

<apex:pageblock id="recordDetails" title="Record Details" >

Then, specify this id on the commandbutton:

 <apex:commandButton action="{!quickUpdat}" value="UpdateRecord" rerender="recordDetails" />
7
  • i tried,but action is not working
    – salesforce
    Jun 27, 2017 at 8:05
  • What do you mean by not working? Jun 27, 2017 at 8:07
  • 1
    i have done as you said, its not working. records are not updating. action function not running.
    – salesforce
    Jun 27, 2017 at 8:09
  • Was it working before adding the rerender attribute? Jun 27, 2017 at 8:17
  • 1
    not updating , same issue
    – salesforce
    Jun 27, 2017 at 8:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .