You need to sign in to do that
Don't have an account?
punith narasimha
How to refresh a component when change and save the picklist values in lightning
Hi friends
My requirement is place a component in opportunity detail page (get the record details by using {!v.recordId}) when change and save the Stage(StageName) picklist values in details page then my component is need to refresh
Here I don’t want to use any button ,link
So I just used aura:handler in this action function I used
$A.get('e.force:refreshView').fire(); but is not working
location.reload(); it is working but problem is entire page will reload number of times i.e it is reload the page continuously it does not stop
<lightning:input label="current record id" aura:id="recid" value="{!v.recordId}" />
<aura:handler name="init" value="{!this}" action="{!c.show}" />
({
show : function(component, event, helper)
{
var recid=component.find("recid").get("v.value");
//alert(recid);
var ledmethod=component.get("c.opprecordidmethod");
ledmethod.setParams({
idd:recid,
});
ledmethod.setCallback(this, function(res){
if (res.getState() === "SUCCESS")
{
var resultval = res.getReturnValue();
component.set("v.stagename",resultval);
if(resultval == "Prospecting"){
component.set("v.Prospectingcurrent", "resultval");
}
if(resultval == "Qualification"){
component.set("v.Qualificationcurrent", "resultval");
component.set("v.Prospectingcomplete", "resultval");
}
$A.get('e.force:refreshView').fire();
//location.reload();
}
});
$A.enqueueAction(ledmethod);
}
})
Please help me friends
Thanks in advance
My requirement is place a component in opportunity detail page (get the record details by using {!v.recordId}) when change and save the Stage(StageName) picklist values in details page then my component is need to refresh
Here I don’t want to use any button ,link
So I just used aura:handler in this action function I used
$A.get('e.force:refreshView').fire(); but is not working
location.reload(); it is working but problem is entire page will reload number of times i.e it is reload the page continuously it does not stop
<lightning:input label="current record id" aura:id="recid" value="{!v.recordId}" />
<aura:handler name="init" value="{!this}" action="{!c.show}" />
({
show : function(component, event, helper)
{
var recid=component.find("recid").get("v.value");
//alert(recid);
var ledmethod=component.get("c.opprecordidmethod");
ledmethod.setParams({
idd:recid,
});
ledmethod.setCallback(this, function(res){
if (res.getState() === "SUCCESS")
{
var resultval = res.getReturnValue();
component.set("v.stagename",resultval);
if(resultval == "Prospecting"){
component.set("v.Prospectingcurrent", "resultval");
}
if(resultval == "Qualification"){
component.set("v.Qualificationcurrent", "resultval");
component.set("v.Prospectingcomplete", "resultval");
}
$A.get('e.force:refreshView').fire();
//location.reload();
}
});
$A.enqueueAction(ledmethod);
}
})
Please help me friends
Thanks in advance
From the standard record save on detail page if you want to refresh the custom component then you have to use the force:refreshView event in handler. Don't fire the event from action it will not work.
So your component should be like below:
<aura:handler name="init" value="{!this}" action="{!c.show}" />
<aura:handler event=”force:refreshView” action=”{!c.show}” />
<lightning:input label="current record id" aura:id="recid" value="{!v.recordId}" />
https://egarakesh.wordpress.com/2017/04/30/salesforce-lightning-record-pages-and-forcerefreshview/
Thanks,
Maharajan.C
All Answers
From the standard record save on detail page if you want to refresh the custom component then you have to use the force:refreshView event in handler. Don't fire the event from action it will not work.
So your component should be like below:
<aura:handler name="init" value="{!this}" action="{!c.show}" />
<aura:handler event=”force:refreshView” action=”{!c.show}” />
<lightning:input label="current record id" aura:id="recid" value="{!v.recordId}" />
https://egarakesh.wordpress.com/2017/04/30/salesforce-lightning-record-pages-and-forcerefreshview/
Thanks,
Maharajan.C