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
Jeffrey KoJeffrey Ko 

Salesforce1 is not refreshing Visualforce page embedded in Standard Page Layout

Hi everyone,

I am experiencing a strange issue with the Salesforce1.  Below is the background info:
  • On an Account page layout, added/embedded a Visualforce page
  • The VF page uses the standard controller; all it does is display a few values of custom fields from the account object (using CSS), to make that section more visually appealing  
  • On the VF page tag, we have the cache=false attribute
Everything works fine on the desktop browser version.  However, when using the Salesforce1 app, on occasion if I view an account #1, go back to do something else, see the account #2, then #3, etc ... after awhile, if I go to account #8, I would see the values from Account #2 in the embedded VF !!!  I would only see the old data from Account #2 within the VF component, and the rest of the page will show the correct Account data from account #8).  This behavior has been inconsistent and cannot be reproduced on demand.  But it will happen after several tries.  It seems that the VF page (which is within an IFRAME) is cached somehow?

Has anyone experienced something similar and can suggest a workaround?  We have reached out to Salesforce Support but no luck from that end yet .... 

We also tried to add a JavaScript code to the end of the VF file to refresh the page once onload, but that didn't seem to fix it ...

Thanks in advance!
 
Gaurav KheterpalGaurav Kheterpal
Can you post your code snippet of how you are navigating back and forth within Salesforce1? Is it with the
sforce.one.navigateToURL() method?

The only cache that Salesforce maintains can be cleared through Settings | Offline Cache in the Salesforce1 navigation menu but I don't think it's related to what you are experiencing.

If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others and improve the overall quality of Discussion Forums.

Gaurav Kheterpal
Certified Force.com Developer| Salesforce Mobile Evangelist| Developer Forums Moderator| Dreamforce Speaker

 
Jeffrey KoJeffrey Ko
We are just using the standard out-of-the-box "Back" button that appears on the Account page layout, so nothing special/custum (please see below).  So users would hit back, then select an Account record, then back, then choose another Account, then look at a related list, etc ... then all of a sudden, when they see a new Account, they would see data from a previously account (only within the VF page embedded).  


User-added image


In an Account page layout, we embedded a VisualForce page (please see below) ... looks to be straight-forward Salesforce functionality to embed VF pages into a standard page layout.


User-added image



Then below is a snippet of the Visualforce page ... very simple logic and displays fields from the Account object only.  
 
<apex:page standardController="Account" sidebar="false" showHeader="false" docType="html-5.0" cache="false">

<apex:stylesheet value="{!URLFOR($Resource.KPIs, 'KPIsCSS.css')}"/>

<div id="main">

    <div id="idBlock1" class="kpiBlock" style="display:{!if(account.kpi__c != 0,"block","none")}">

        <div class="inner">
            <article>
                <div class="kpiLeftColumn">
                    <span class="kpiLabel">{!$ObjectType.account.fields.kpi__c.label}</span>
                   <br />
                    <span class="kpiValue">{!VALUE(TEXT(account.kpi__c))}%</span>
                </div>
                <div class="kpiRightColumn"></div>
            </article>
        </div>

    </div>
</div>
</apex:page>


So basically, on some occasions, the fields that are displayed in this KPI Visualforce page will not be correct (i.e. it shows data from previously viewed accounts).   We tried clearing the user's cache, etc ... no luck so far.  :(

Has anyone out there experienced something simialr with this issue in the Salesforce1 app?  Any suggestions/ideas/recommendations on what may caused this and potential work arounds?  Your ideas will be deeply appreciated!  :)
Gaurav KheterpalGaurav Kheterpal
Your issue looks similar to the one described here (https://developer.salesforce.com/forums?id=906F0000000966AIAQ). I would recommend trying out this approach to see if it makes a difference.
 
<apex:form>
<apex:actionFunction name="ajaxSetClientLoaded" action="{!setClientLoaded}" immediate="true" rerender="DeferredLoad"/>
<script type="text/javascript">var cached_onload = window.onload; window.onload = function() { ajaxSetClientLoaded(); if (cached_onload != null) cached_onload(); }</script>

<apex:outputPanel id="DeferredLoad">
<apex:outputPanel rendered="{!NOT(clientLoaded)}">Loading...</apex:outputPanel>
<apex:outputPanel rendered="{!clientLoaded}">
<!-- end workaround -->

... your deferred page contents here ...

</apex:outputPanel>
</apex:outputPanel>
</apex:form>
 
and on the controller:
 
 
1
 
boolean clientLoaded = false;
public boolean getClientLoaded() {
return clientLoaded;
}
public PageReference setClientLoaded() {
clientLoaded = true;
return null;
}
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others and improve the overall quality of Discussion Forums.

Gaurav Kheterpal
Certified Force.com Developer| Salesforce Mobile Evangelist| Developer Forums Moderator| Dreamforce Speaker