I am attempting to emulate a Confirm process that was once handled well by a Javascript button. The idea is to ask for a Confirmation when attempting to deactivate a record.

To do this, I am creating a simple VF page using an controller extension. The PageMessages receive an INFO level confirmation message, and the button will call a method to deactivate and save the record, then redirect back to it:

From the record detail in Lightning Experience, I have a quick action button that references a VF page.

Ultimately the process is working, but when the page redirects back to the original record, the Active switch is still appears as checked, even though one or two hard refreshes show that its actually deactivated in the database. Here is the code

<apex:page standardController="Activity__c" extensions="Deactivate">
<apex:pageMessages />
<apex:form >
        <apex:pageBlockButtons location="top">
            <apex:commandButton action="{!DeActivate}" value="DeActivate Activity" rendered="{!Active = true}"/>
            <apex:commandButton action="{!Cancel}" value="Cancel" />

public with sharing class DeactivateController{
Public Activity__c pActivity {get; set;}
Public Boolean Active {get; set;}

public Deactivate(ApexPages.StandardController ctr){
    this.pActivity = (Activity__c) ctr.getRecord();
    this.pActivity = [Select id, Active__c from Activity__c Where Id = :this.pActivity.Id];
    Active = this.pActivity.Active__c;

private void confirm(){
    if (Active){
        ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Confirm Deactivate?'));

public pageReference DeActivate(){
    pActivity.Active__c = False;
    update pActivity;
    PageReference pageRef = new PageReference('/'+pActivity.Id);

    return pageRef;


I've also tried new PageReference('/one/one.app#/sObject/'+pActivityId+'/view'); as well as the full URL with https In all cases, the Record page returns, but Active still appears checked, even though it isn't in the database. If I refresh the page a couple of times, it finally comes up correct.

  • I actually have to refresh the page one or two times after the operation to show the correct value. I don't understand that at all.
    – VeMan
    Aug 10, 2017 at 18:00
  • This page will not compile nor will the class due to name mismatches
    – Eric
    Aug 22, 2017 at 4:40
  • Did you ever find a solution to this?
    – Marc M.
    Nov 6, 2017 at 14:17
  • I don't think we did. Ultimately we chose to accept that the deactivation was taking place and redirected the user to another page.
    – VeMan
    Nov 6, 2017 at 18:21
  • Just in case you never figured this out, you may want to have a look at my solution.
    – Mr. B
    Dec 10, 2019 at 20:22

2 Answers 2


I finally figured this out. This is actually a known issue between VF and background Apex changes (thanks Salesforce), along with navigation back to a Standard Page via PageReference:


I found this Post that explained how to use remoting to force the refresh (in Lightning):


Unfortunately, that also did NOT (or no longer does) work either. It did however lead me to Googling caching issues with sforce.one.navigateToSObject in Lightning, where I found a Post that said sforce.one.back(true) does work in Lighting. Finally, I got it to work, using this approach. The following example illustrates my final solution:

Visual Force .page file:

<apex:page controller="YOUR_CONTROLLER" action="{!Launch}" cache="false" 

   <script src="/soap/ajax/38.0/connection.js" type="text/javascript"></script>
   <script src="/soap/ajax/38.0/apex.js" type="text/javascript"></script>
   <script type="text/javascript">

      // Back NAV.Refreshed
      sforce.one.back(true); // While sforce.one.navigateToSObject(YOUR_ID) did NOT 
                             // refresh, sforce.one.back(true) did refresh


Apex Controller

global class YOUR_CONTROLLER  
   public void Launch()
      // Your update logic goes here (will properly refresh on backward navigation)

Here is an easy solution to this problem. reload the page using apex:commandLink with target ="_top" OR target="_parent".

At visualforce page have this

<apex:page controller="xyz" lightningstylesheet="true">
Your any page side tag
<apex:commandLink action="{!redirectWithRefreshValue}" target="_top" >Click to go back to Lightning Detail record Page</apex:commandLink>


//Apex Controller Code method
public PageReference redirectWithRefreshValue(){
 return new PageReference('/'+recordId);

You must log in to answer this question.

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