8

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.

2 Answers 2

8

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!

3
  • Thanks for the response! This does seem to be a working solution when using a publisher action. In my original question I was using a custom button, in that situation I believe sforce.one.navigateToSObject(result,"detail"); isn't supporting a proper refresh of the original record. I can accept this answer and go the publisher action route but I really was hoping to get the custom button method to work. Apr 16, 2014 at 3:03
  • Been struggling with this issue too. I'd like to point out that sforce.one.back() allows you to pass in a boolean to refresh if possible. Ironically, I just realized back() isn't in the documentation I found it on some cheatsheet pdf. In my particular case I can use sforce.one.back(true); to go back to my object page and refresh. Hope it helps.
    – chad
    Jun 18, 2014 at 13:44
  • Could you please point to the documentation which says that navigateToSObject doese not work properly?
    – Seyitbek
    Nov 12, 2020 at 21:42
0

I am not able to comment for lack of reputation . I am struggling with this same situation .

I want to try Carolina's solution but I do not have much idea about publisher actions .

Is it possible to use publisher actions without creating a custom action ?

Any help guys ?

You must log in to answer this question.

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