This is an Embedded VF page on the standard Contact detail page. I am having a Command button on my VF page with following JS function:

<apex:commandButton value="Click ME" onclick="jsFunction(); return false;"/>
function jsFunction(){
   if(confirm('Do you want to continue?')){ 
function processing(){
    <!-- Action functions to update the Contact fields-->
function pageReload(){

Page reloads successfully(on two occasions), but I am not seeing the updated value of the Parent Contact record reflecting immediately. I need to refresh the browser window manually to see the new changes. Am I missing something here?

1 Answer 1


No, that's expected. In fact, this probably shouldn't work at all, because you're prematurely cancelling the actionFunction (it's asynchronous). What you end up with is a situation that's a race condition; will the network callout reach the server before the page unloads (which automatically terminates all network activity)?

Instead, make sure you put pageReload in the onComplete for the actionFunction:

<apex:actionFunction name="updateContact" action="{!...}" oncomplete="pageReload()" />
  • Thing is, I am having a Status (Processing..) in the actionFunction, I wanted to reload the page before the Processing timer(5000ms) ends. That way end users will not get to see process completion and page loads in between.
    – SatyaV
    Mar 29, 2018 at 15:48
  • 2
    @ArnoldJr. At any point before the call returns, the new data hasn't been committed to the database, so reloading won't show the new data. You need to wait until the transaction completes, and no sooner. Using oncomplete is the ideal situation, but you might also be able to use onbeforedomupdate instead; that's the absolutely earliest point in time that you can guarantee the data is committed.
    – sfdcfox
    Mar 29, 2018 at 15:52
  • I see. I think I would go with the onbeforedomupdate, as I can see from the documentation too. Great, thanks for the explanation.
    – SatyaV
    Mar 29, 2018 at 15:58
  • Congratulations @sfdcfox for reaching 200k officially.
    – SatyaV
    Apr 30, 2018 at 13:41

You must log in to answer this question.

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