Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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>

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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

share|improve this answer
    
Thanks @Daniel Ballinger.Just to retrieve one value we need to write query.I think formula fields should evaluate real time.There is an idea posted on this success.salesforce.com/ideaView?id=08730000000BqqVAAS –  sf.dev Dec 18 '13 at 19:43

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.