You need to sign in to do that
Don't have an account?
Adeesh maddukuri
Dependency between custom component and standard page in lightning
I have custom component "CaseAsset" on case object which displays Asset values. After updating Asset object I want to refresh that component automatically to show updated values. I used below code to achieve this but feels like its not efficient way. I checked online and read about aura dependency but not sure which resource to use. Please let me know if there is any other way. Thanks in advance.
Helper:
<aura:component implements="flexipage:availableForRecordHome,force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,force:hasSObjectName" controller="CaseAssetController" access="global" > <aura:attribute name="caseAsset" type="Case" /> <aura:attribute name="recordId" type="Id" /> <aura:handler name="init" action="{!c.fetchCs}" value="{!this}" /> <aura:dependency resource="markup://force:recordSave" type="EVENT" /> <aura:handler event="force:refreshView" action="{!c.fetchCs}" /> <lightning:card title="Asset With Support"> <p class="slds-p-horizontal_small"> <ui:outputText class="slds-text-body_regular" value="{!v.caseAsset.Asset.Name}"/><br /> <ui:outputText class="slds-text-body_regular" value="{!v.caseAsset.Asset.Price}"/><br /> <ui:outputText class="slds-text-body_regular" value="{!v.caseAsset.Asset.Status}"/><br /> <ui:outputText class="slds-text-body_regular" value="{!v.caseAsset.Asset.SerialNumber}"/><br /> </p> </lightning:card> </aura:component>Controller:
({ fetchCs : function(component,event,helper){ helper.calltoApex(component,event); window.setInterval( $A.getCallback(function() { helper.calltoApex(omponent,event); }), 5000 ); },
Helper:
({ calltoApex : function(component, event) { var action = component.get("c.getCaseList"); var caseId = component.get("v.recordId"); action.setParams({ caseId: caseId }); action.setCallback(this, function(a) { if (a.getState() === "SUCCESS") { component.set("v.caseAsset", a.getReturnValue()); } else if (a.getState() === "ERROR") { $A.log("Errors", a.getError()); } }); $A.enqueueAction(action); } })