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
m 10m 10 

how to write controller for refresh component

how ot write below component contoller and helpr for lighting button in component please help me

<button class="slds-button slds-button_neutral" >
                                    <lightning:icon class="slds-button__icon slds-button__icon_left" iconName="utility:refresh" size="x-small" alternativeText="Refresh" />
                                        Refresh
                                    </button>
VinayVinay (Salesforce Developers) 
Hi,

Please find below sample code to refresh a lightning component.


<aura:component controller="editRecordSimulationController"
                implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,force:hasSObjectName">
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    <aura:dependency resource="markup://force:editRecord" type="EVENT" />
    
    <aura:handler event="force:refreshView" action="{!c.doInit}" />


    
    <aura:attribute name="recordId" type="string" />
    <aura:attribute name="accType" type="String" />
    <aura:attribute name="accObj" type="account" default="{ sObjectType: 'Account'}"/>
    
    
    <ui:inputText label="Record Id" value="{!v.recordId}" required="true"/>
    <ui:button class="btn" label="Submit" press="{!c.setOutput}"/>
    
    <br />
    <br />
    <br />
    Account Type: <ui:outputText value="{!v.accObj.Type}" />
</aura:component>

Controller:
========

({
    doInit : function(component, event, helper) {
        var recordId = component.get("v.recordId");
        var action = component.get("c.getTypeFromAccount");
        action.setParams({
                recordId: recordId
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var acc = response.getReturnValue();
                component.set("v.accType", acc.Type);
                component.set("v.accObj", acc)
            }
        });
        
        $A.enqueueAction(action);
    },
    setOutput : function(component, event, helper) {
        var editRecordEvent = $A.get("e.force:editRecord");
        editRecordEvent.setParams({
             "recordId": component.get("v.recordId")
        });
        editRecordEvent.fire();
    }
})

Hope this should help you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks,
Vinay Kumar
 
losl liyalosl liya
The most ideal approach to use these pills is the point at which you have an everyday practice of burning through effort close by. It will give you the best outcomes when you have a set exercise center routine where you lose vitality.  new leaf cbd oil (http://oliveleafbistro.com/new-leaf-cbd-review/)The vitality discharge routine must be kept up to have the best aftereffects of the item.