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
AK_SmithAK_Smith 

How to refresh the parent page after a Save action in a VF page in SF1

Hello! Please help me with the code below.
I created an action button that opens the VF page on SF1 record
After i hit SAVE button the  VF page closes but values in Project__c.l__c/Project__c.ll__c stays the same (old)
I have to pull down the page to see the results. 
how to automatically update the record window after clicking on the save button?
 
<apex:page standardController="Project__c" id="page" docType="html-5.0">
<script>
geoFindMe()
function geoFindMe() {
  var output = document.getElementById("out");

  if (!navigator.geolocation){
    output.innerHTML = "<p>Geolocation is not supported by your browser</p>";
    return;
  }

  function success(position) {
    var latitude  = position.coords.latitude;
    var longitude = position.coords.longitude;

    document.getElementById('page:form:lati').value = latitude.toString().replace(".",",")  ;
    document.getElementById('page:form:long').value = longitude.toString().replace(".",",")  ; 
    document.getElementById('page:form:SF1').checked = true;

   
  };

  function error() {
    output.innerHTML = "Unable to retrieve your location";
  };

  navigator.geolocation.getCurrentPosition(success, error);
}
</script>


<apex:form id="form">

  <div style="display:none;"></div>
latitude :<apex:inputField id="lati"  value="{!Project__c.l__c}" /> <br></br>
longitude :<apex:inputField id="long" value="{!Project__c.ll__c}" />
<apex:inputField id="SF1" value="{!Project__c.SF1__c}" />


<apex:commandButton action="{!save}"  value="Save"/>

                     
                     
                     
</apex:form>

</apex:page>

 
Suraj TripathiSuraj Tripathi
Hi Ak,

From your code snippet,

Please try to replace this line:
<apex:commandButton action="{!save}" value="Save"/>

with this line,
<apex:commandLink value="Save" action="{!save}" target="_parent" styleClass="btn" style="text-decoration:none;padding:4px;">

we can give target attribute to refresh our parent page.


If this helps you, please mark this answer as best 

Regards
Suraj
AK_SmithAK_Smith
Hello!
It works, but open full page, not SF1
Suraj TripathiSuraj Tripathi
Hi AK,

then, please try this, it may help you

use this code inside your script tag:
 
<script>
function  refresh(){
   sforce.one.back(true);
}
</script>


and plzz call this on your save action button:
 
<apex:commandButton action="{!save}" value="Save" oncomplete="refresh()"/>


Hope it will be helpful to refresh your SF1 page

Regards
Suraj
 
AK_SmithAK_Smith
Hi Suraj! Thank you for your reply
Done but it use cached page 
SandeeVySandeeVy
Hi Suraj

Good Evening

I was searching for an issue which is almost similar to this issue.

I am using the below code for my Account - Competitor(Custom Object)..When I am adding new competitor and click on Save button, I have to manually refresh the page to see the changes and when I use the below code it is working fine but the Salesforce One is not working correctly.

<apex:commandLink value="Save" action="{!save}" target="_parent" styleClass="btn"  onClick="refresh()">

and I have used the script code because we are using Salesforce one(Mobile App) as the sales users are using mobile for most of the time.
<script> function refresh(){ sforce.one.back(true); } </script>

My issue is when I am using this code ...

I am getting the page refreshed in the parent page (which is Account here and the child page as Competitor) but the Salesforce One is not working correctly.

Please let me know your thoughts