[SalesForce] salesforce1 navigation usage of sforce.one.navigateToSObject(recordId,view) doesn’t refresh record

In salesforce1, from an opportunity a user clicks a custom button to go to a visualforce page which updates a field on the opportunity. After the update I use the javascript function sforce.one.navigateToSObject(recordId,view); on the client side of my visualforce page to get back to the record.

There are two problems with this.
The first is that the updated opportunity doesn't get reloaded (if I had updated the name field it doesn't show until backing out of the record and reloading).

The second issue that clicking edit on the opportunity will pull up multiple edit record windows in salesforce1 causing the following error:
'Looks like there's a problem. This record was modified by during your edit session. Make a note of the data you entered, then reload the record and enter your updates again.'

I am looking for a way to properly navigate back to my updated record from a visualforce page and avoid these issues.

Best Answer

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? I had 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' 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!

Related Topic