2

I have apex column to display the formula field on visualforce page.I am rendering the page on submit of the record and then displaying the newly created record.But issue is (Fiscal_Year_Start_Date__c)formula field value is displaying blank in the results section.Whereas if i go to record detail page I see the value but not on the vf page.

public class SerndingEventController {


 public SerndingEventController(){

 seriesId = ApexPages.currentPage().getParameters().get('id');
 fevent = new Fund_Event__c();
 showFields = false;
}


   public PageReference Save(){
   newfevenlist = new list<Fund_Event__c>();
   system.debug('.....'+fevent);
   fevent.Series__c = seriesId;
    showFields = true;

    fevent.RecordTypeId= rectype;
    newfevenlist.add(fevent);
    insert newfevenlist;

 return null;
}

 public PageReference Cancel(){
  return null;
   }

  }

Controller:

<apex:page Controller="SerndingEventController">
<apex:form >
<apex:pageBlock title="New Funding Event" mode="edit">

  <apex:pageblockButtons location="top">
<apex:commandButton value="Submit" action="{!save}" reRender="result,fields">
</apex:commandButton>
<apex:commandButton value="Cancel" action="{!cancel}" immediate="true">
</apex:commandButton>
</apex:pageblockButtons>
 <apex:pageBlockSection id="fields">
 <apex:pageBlockSectionItem >
     <apex:outputLabel value="Record Types" /> 
                <apex:selectList value="{!RecordType}" size="1">
                    <apex:selectOptions value="{!rectypes}" />
                </apex:selectList>           
  </apex:pageBlockSectionItem>

  <apex:inputField value="{!fevent.Project__c}" rendered="{!showFields==false}"/>
  <apex:inputField value="{!fevent.Status__c}" rendered="{!showFields==false}"/>
  <apex:inputField value="{!fevent.Fiscal_Year__c}" rendered="{!showFields==false}"/>
  <apex:inputField value="{!fevent.Number_of_years_of_the_Funding_Event__c}" rendered="{!showFields==false}"/>
  <apex:inputField value="{!fevent.Amount__c}" rendered="{!showFields==false}"/>
  <apex:inputField value="{!fevent.Budget_Expenses__c}" rendered="{!showFields==false}"/>
  </apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock id="result" >
     <apex:pageBlockTable value="{!newfevenlist}" var="fundevent">

    <apex:commandLink action="{!editFundingEvents}" rerender="result">Edit<apex:param name="editid" value="{!fundevent.id}"/></apex:commandLink>
     </apex:column>
     <apex:column value="{!fundevent.Grant__c}" rendered="{!fundevent.Id != editEvent.Id}"/>
     <apex:column value="{!fundevent.Grant__c}" rendered="{!fundevent.Id != editEvent.Id}"/>  

     <apex:column value="{!fundevent.Amt__c}" rendered="{!fundevent.Id != editEvent.Id}"/>
     <apex:column value="{!fundevent.Budget_Expenses__c}" rendered="{!fundevent.Id != editEvent.Id}"/>
     <apex:column value="{!fundevent.Fiscal_Year_Start_Date__c}"/>           
  </apex:pageBlockTable>       
  </apex:pageBlock>

2 Answers 2

3

After inserting newfevenlist into the database try retrieving it out again using SOQL to get the updated formula field values.

1
2

After you have inserted the record , I think you will have to query the field Fiscal_Year_Start_Date__c for the inserted record and use the result to display the formula field value. Implying that the formula field value has to be retrieved from the database.It will not be available automatically in your record variable.

You must log in to answer this question.

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