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
BDArnzBDArnz 

Why isn't my field refreshing?

 

I have a field (Report_Filed__c) in a custom object (Service__c) that I want to insert a date stamp into.  I'm displaying the field in a page block on my VF form.  I have a button that sends out an email version of a report and then inserts the current date into the field.

 

After the email is sent, I use a pagereference in the controller to reload the page.  Unfortunately the newly updated information in the field does not display until I hit my browser's refresh button.

 

Can someone tell my why this is or how to fix it?

 

Here's the Code snippet from the page:  (the rerender in there doesn't fix the problem...)

<apex:form > <apex:pageblock Title="Hello {!$User.FirstName} {!$User.LastName}" id="TitleBlock"> <h1> Version 2.0 </h1><br /> The report was filed on: <apex:outputtext value="{!Service__c.Report_Filed__c}"/><br /> <apex:pageBlockButtons > <apex:commandButton action="{!submitReport}" value="Submit Report" rerender="TitleBlock"> </apex:commandButton> </apex:pageBlockButtons> </apex:pageblock> </apex:form>

 

 

 

Here's the controller:

 

 

public pagereference submitReport(){ //generate the email (code omitted for brevity...) Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail}); //insert the date into the field this.svc.Report_Filed__c = datetime.now(); update this.svc; PageReference editCase = new PageReference('/apex/service_detail_2?id='+this.svc.id); return editCase; }

 

 

Thanks for any insight you can provide...

 

Best Answer chosen by Admin (Salesforce Developers) 
BDArnzBDArnz

That did it.

 

I figured I missing something like that.

 

Thanks for your help.

All Answers

dev_forcedev_force

try

 

 

PageReference editCase = new PageReference('/apex/service_detail_2?id='+this.svc.id); editCase.setRedirect(true); return editCase;

 

 

 

BDArnzBDArnz

That did it.

 

I figured I missing something like that.

 

Thanks for your help.

This was selected as the best answer