1

I have written a VF Page & Apex Class to update some value on a object when clicked on a button & redirect back to detail record page. This logic works perfectly fine in classic mode but the same logic doesn't immediately reflect the update value in lightning i have to refresh the detail page to see the updated value.

Here is the code:

Visualforce Page

<apex:page standardController="Apttus_Proposal__Proposal__c" extensions="Apts_OSW_quoteChangeController" action="{!quoteChange}" cache="false">
</apex:page>

Apex Class

public class Apts_OSW_quoteChangeController {

public String proposalId{get;set;}
public String status{get;set;}
public String identityNumber{get;set;}

public Apts_OSW_quoteChangeController(ApexPages.StandardController stdController){

    //Getting the required parameters from the button/formula field
    proposalId = apexpages.currentpage().getparameters().get('proposalId');
    status = apexpages.currentpage().getparameters().get('status');
    identityNumber = apexpages.currentpage().getparameters().get('identityNumber');
}

public PageReference quoteChange(){
    Apttus_Proposal__Proposal__c quote = [select Id,Apts_OSW_Profsum_Status__c from Apttus_Proposal__Proposal__c where id =: proposalId]; //querying the status of the proposal

    /**
     * Using the identity number to basically identify the intended operation to be done, it's like a unique identifier for every operation done the quote process flow
    **/
    if(quote.Apts_OSW_Profsum_Status__c != NULL){
        if(quote.Apts_OSW_Profsum_Status__c == 'Draft' && identityNumber == '1') { //If the status is Draft and identity number is 1
            quote.Apts_OSW_Profsum_Status__c = 'Pending CFM Validation';
            quote.Apts_OSW_Submitted_for_Finance_Review_On__c = System.now(); //Assigning the date on which the quote has been submitted for Finance Review
        }
        else if(quote.Apts_OSW_Profsum_Status__c == 'Pending CFM Validation' && identityNumber == '2'){ //If the status is Pending CFM Validation and identity number is 2
            quote.Apts_OSW_Profsum_Status__c = 'Pending R Review';
            quote.Apts_OSW_Submitted_for_Pricing_Review_On__c = System.now();
        }
        else if(quote.Apts_OSW_Profsum_Status__c == 'Pending R Review' && identityNumber == '3'){ //If the status is Pending R Review and identity number is 3
            quote.Apts_OSW_Profsum_Status__c = 'Approved';
            quote.Apts_OSW_Approved_On__c = System.now(); //Assigning the date on which the quote has been approved
        }
        else if(quote.Apts_OSW_Profsum_Status__c == 'Draft' && identityNumber == '4'){ //If the status is Draft or CFM Validated and identity number is 4
            quote.Apts_OSW_Profsum_Status__c = 'Pending R Review';
            quote.Apts_OSW_Submitted_for_Pricing_Review_On__c = System.now(); //Assigning the date on which the quote has been submitted for pricing review
        }
        else if(quote.Apts_OSW_Profsum_Status__c == 'Pending R Review' && identityNumber == '5') { //If the status is Pending CFM Validation or Pending R Review and identity number is 5
            quote.Apts_OSW_Profsum_Status__c = 'Rejected';
        }
        else if(quote.Apts_OSW_Profsum_Status__c == 'Pending CFM Validation' && identityNumber == '6') { //If the status is Pending CFM Validation or Pending R Review and identity number is 5
            quote.Apts_OSW_Profsum_Status__c = 'Draft';
            quote.Apts_OSW_Submitted_for_Finance_Review_On__c = NULL;
        }
        else if(quote.Apts_OSW_Profsum_Status__c == 'Pending R Review' && identityNumber == '7') { //If the status is Pending CFM Validation or Pending R Review and identity number is 5
            quote.Apts_OSW_Profsum_Status__c = 'Pending CFM Validation';
            quote.Apts_OSW_Submitted_for_Pricing_Review_On__c = NULL;
        }
        else if((quote.Apts_OSW_Profsum_Status__c == 'Approved' || quote.Apts_OSW_Profsum_Status__c == 'Rejected') && identityNumber == '8') { //If the status is Pending CFM Validation or Pending R Review and identity number is 5
            quote.Apts_OSW_Profsum_Status__c = 'Pending R Review';
            quote.Apts_OSW_Approved_On__c = NULL;
        }
        else if(quote.Apts_OSW_Profsum_Status__c == 'Pending R Review' && identityNumber == '9') { //If the status is Pending CFM Validation or Pending R Review and identity number is 5
            quote.Apts_OSW_Profsum_Status__c = 'Draft';
            quote.Apts_OSW_Submitted_for_Pricing_Review_On__c = NULL;
        }
        quote.Dummy_Check__c = true;
        update quote; //update the quote with new status
    }

    pageReference pg = new pageReference('/'+proposalId); //referencing the same proposal page
    return pg;
}
}
  • cant see any re-render tag in VF – Pranay Jaiswal Nov 12 at 15:14
  • @PranayJaiswal There is a button on detail page record which when clicked will invoke the apex page & controller logic will execute & update the some field on my custom object & redirect back to detail page. At that time updated value is not reflected immediately in lightning, user would have to refresh the page. – Ravindra D Nov 20 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.