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
Tulasiram ChippalaTulasiram Chippala 

How to refresh lightning component placed on opportunity detail page

We are displaying one banner on the Opportunity page. If Opportunity is edited this banner has to be refreshed and call apex method. 
I tried with below code but recursion is happening in page refresh, it is not stopping refresh call.
<aura:handler event="force:refreshView" action="{!c.onSuccessMethod}" />
 
onSuccessMethod : function(component, event, helper){
        console.log("Loading on Success");
        $A.get('e.force:refreshView').fire();
        
    }
 
<aura:component controller="PositionsStatus" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName" 
                access="global">
	<aura:attribute name="statusMessage" type="String" default=""/>
  	<aura:attribute name="ShowMessage" type="boolean" default="true"/>
    <aura:attribute name="sobjecttype" type="String" default="{!v.sObjectName}"/>  
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
	<aura:handler event="force:refreshView" action="{!c.onSuccessMethod}" />

    <aura:if isTrue="{!v.ShowMessage}">
    <div  class="">
        <div aura:id = "barId" class="greenColor slds-notify slds-notify_alert slds-theme_alert-texture">
            <span class="slds-assistive-text ">warning</span>
            <h1>{!v.statusMessage}</h1>
            <div class="slds-notify__close">  
            </div>
        </div>
    </div>
        </aura:if>
</aura:component>
Please help me with this. Thanks.
 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Tulasiram,

You can try reloading the page after saving the changes so that the details are updated.

I hope this helps.

Regards,
Anutej