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
Nitin SehgalNitin Sehgal 

Need to refresh Salesforce1 VF page

Hello Everyone,

I am new to salesforce1 and having problem while working with VF pages. I have a VF page that saves some records. When i edit any record and updates the value, the value is changed in the database but doesn't reflect on the standard detail page but when i refresh my page then the updated value appeared. I think old value is displaying from the cookies. I am using salesforce1 mobile browser app. Can anyone tell me how can i get the refreshed value?

Thanks in advanced
Ashish_SFDCAshish_SFDC
Hi Nitin, 


See the sample and related discussion in the thread below, 

https://developer.salesforce.com/forums/ForumsMain?id=906F00000009E5wIAE


Regards,
Ashish
Nitin SehgalNitin Sehgal
Hi Ashish,

I think this is not related to Salesforce1 app. I am working on Salesforce1 and i need to use "pull to refresh" to refresh the records. I want it to get the updated records automatically. I am redirecting through javascript library i.e. sforce.one.navigateToSObject(recordId,view) but when it takes me to the detail page of that record, the page shows the old record and i have to refresh it to get the updated record.
Ashish_SFDCAshish_SFDC
Hi Nithin, 


Not exactly sure but can you have the pagereference to the OnSave action and see if it redirects to a new page with the list. 

Looks like it currently is just doing a 'Go back to the previous page' action. 


Regards,
Ashish

APN09217013342392059APN09217013342392059
Try to use "Rerender" to render the components on the page that shows the updated value
Carolina Ruiz MedinaCarolina Ruiz Medina
Hi Nitin,
I've been doing some development in Salesforce1, and I found the same behaviour that you are facin at the moment when I use VF pages. In my case I have a custom Chatter Action where I update some fields on a record at the same time I have other logic. When the action is finish , it take me back where I specified that is the same record where I started the action , however I expected to see the changes but in order to see them I have to pull for refresh. 
However if I don't use custom Chatter Action, if I use a no custom chatter action like update record one , when the action is finished it takes me back to the record and in this case the Record reflects the changes. 
I have a case with Salesforce to know why is this behavior. Let you know as soon I have something.
Cheers.
Nitin SehgalNitin Sehgal
Thanks Carolina,

I also tried to submit a case to salesforce about this but couldn't make it. So waiting for your answer. Thanks again. :)
Carolina Ruiz MedinaCarolina Ruiz Medina
No problem. I promisse keep you updated . :) 
Thanks to you!
APN09217013342392059APN09217013342392059
Any update on this ? I am also running into the same issue with "Custom Visualforce" publisher action on salesforce1.
My action update some fields on the record. and I close the publisher, it shows me the same rerord with old values.
Carolina Ruiz MedinaCarolina Ruiz Medina
Hi!!
I still have the case open. 

They told me that the issues was the use of JavaScript Remoting. However I tested out without it and still not working. 
They are working on it still :( 

Let you know at the end of the week how it is going. Also I'll share the test code that I send them , hopefully today.

Cheers,
Carolina.
Carolina Ruiz MedinaCarolina Ruiz Medina
Hi all, 
As I promissed here it is the result in order to update the record :


As per the updates, the navigateto does not work properly. Seems like this is known issue to salesforce and possible it will be fixed in next few releases. ( safe harbor)

Then what to do meanwhile?
Having the same issue and after chatting with Salesforce the solution below is the one that I'm using meanwhile. It works :)


Solution : --------------------------------------------------------------------------
Sfdc.canvas.publisher.publish({name: "publisher.close", payload:{ refresh:"true"}});

Then this could be your page: -------------------------------------------------------

<apex:page showHeader="true" standardController="Account" extensions="AccountController" sidebar="true">

<!-- <script type="text/javascript"> -->
<script type='text/javascript' src='/canvas/sdk/js/publisher.js'/>
<script src="https://mobile1.t.salesforce.com/soap/ajax/30.0/connection.js" type="text/javascript" />
<script>
function myUpdateAccount()
{
var accountId = document.getElementById('accountId').value;

Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.AccountController.accountUpdateNumberField}', accountId, function(result, event)
{


<!-- if(result!=null) sforce.one.navigateToSObject(result,"detail"); -->
Sfdc.canvas.publisher.publish({name: "publisher.close", payload:{ refresh:"true"}});


});

}
</script>

<input type="text" name="name" id="accountId" value="{!viewState.accountId}"/>

<a href="#" data-role="button" class="updateNotify" id="sendInvoicesMyself" onclick="myUpdateAccount()">Update Account</a>


</apex:page>


Hope it helps!

Kind Regards,
Carolina.
vanessenvanessen
This is good. Found this too, but what im facing right now , is that i need to go to my created record, and the previous screen is not my new created record. Thus, ho can i achieve this with the publisher action ? using the sforce navigation it works, but sforce navigation do not work with publisher action. Does anyone has a solution?
Nilesh AdkarNilesh Adkar
Scenario for refreshing detail page that is working for me.
Custom button with VF page on detail page.
when clicked, executes remote method, updates data and comes back to detail page and refreshes detail page with updated data.

<apex:page standardController="Lead" extensions="sample_Helper">
<script src="/soap/ajax/29.0/connection.js"></script>
<script type='text/javascript' src='/canvas/sdk/js/publisher.js'/>
<script src="https://mobile1.t.salesforce.com/soap/ajax/30.0/connection.js" type="text/javascript" />
<script type="text/javascript">

window.onload=function(){

var leadId = '{!Lead.Id}'; 
var ownerId = '{!Lead.ownerId}'; 
alert('continue?');
Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.sample_Helper.deleteOtherUserShare}',leadId ,ownerId ,function(result, event){window.close();});

if( (typeof sforce != 'undefined') && (sforce != null) ) {
// Salesforce1 navigation

sforce.one.back(true);

Sfdc.canvas.publisher.publish({name: "publisher.refresh", payload:{ refresh:"true"}});

}
Regards,
Nilesh

Theertha PrasadTheertha Prasad
Hi..,
Has Anybody found the solution for Nitin Sehgal's senario???
Carolina Ruiz MedinaCarolina Ruiz Medina
At moment I'm using :
Sfdc.canvas.publisher.publish({name: "publisher.close", payload:{ refresh:"true"}});


Hope it helps. 
Chidambar KulkarniChidambar Kulkarni
Hi,

I am new to Salesforce1. Can you please explain how the '{!$RemoteAction.AccountController.accountUpdateNumberField}' works? 
In general, how should the apex controller extensions="AccountController" look like.

Thanks 
Paul DevenportPaul Devenport
Going through the pain of lightning conversion of VF pages...
This seems to work with the save and cancel buttons.  Assuming that our pre-lightning save/cancel methods already worked in the controller.

<apex:commandButton id="btnSave" value="Save" action="{!save}" oncomplete="backIfNoErrors(); "  immediate="false" reRender="errmsg, errmsgBottom" status="actStatusId" />
<apex:commandButton id="btnCancel" value="Cancel" action="{!cancel}" onclick="back(); " immediate="false" ></apex:commandButton>


<script type="text/javascript">
     function back() {
        sforce.one.back(false);
    }
    function backIfNoErrors() {
        var errs = jQuery('.messageCell').length;
        if (errs == 0){
            sforce.one.back(true);
        }
    }
</script>