• deechan
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hi Guys,

I'm trying to build a lightning component which will be used on Opportunity lightning UI. The component is placed in the right panel. The component loads pretty well on any Opportunity record view.

The problem here is when I try to update the opportunity record (which comes as popup block) the component in the right panel is not getting refreshed. By this the updated values are not showing up on the lightint component.

Need to find a way to refresh the lightning component on record save.

Any help would be appreciated!! 

Thanks
Shravan 
I am working with the force:editRecord event to handle the edit of a list of objects in a lightning component. I am able to return and display the list of objects each list item has an edit button that calls a function like what is displayed in this article:
https://developer.salesforce.com/docs/atlas.en-us.200.0.lightning.meta/lightning/ref_force_editRecord.htm (https://developer.salesforce.com/docs/atlas.en-us.200.0.lightning.meta/lightning/ref_force_editRecord.htm" target="_blank)
I've only been able to get this to work in a developer org if I add the component to an object page.

The problem is I need to update the list with the newley updated values but haven't been able to find any reference to handling the save event on the editRecord Modal popup. Any assistance would be great. 

https://developer.salesforce.com/docs/atlas.en-us.198.0.lightning.meta/lightning/ref_force_recordSaveSuccess.htm

Here is basic example of what I am trying to do. Adding the component to the account page I can click the button edit the record and hit save. The Account compact data  in the top of the page updates but what's in the component does not.

Component Code:
<aura:component controller="editRecordSimulationController"
                implements="force:appHostable,
                            flexipage:availableForAllPageTypes,
                            force:hasRecordId">
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    <aura:dependency resource="markup://force:editRecord" type="EVENT" />
    <aura:handler name="handleEdit" event="force:editRecord" action="{!c.doInit}" />
    <aura:handler name="handleSaveSuccess" event="force:recordSaveSuccess" action="{!c.doInit}" />
    
    <aura:attribute name="recordId" type="string" />
    <aura:attribute name="accType" type="String" />
    
    
    <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.accType}" />
</aura:component>

Component Controller Code:
({
    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 accType = response.getReturnValue();
                component.set("v.accType", accType);
            }
        });
        
        $A.enqueueAction(action);
    },
	setOutput : function(component, event, helper) {
        var editRecordEvent = $A.get("e.force:editRecord");
        editRecordEvent.setParams({
             "recordId": component.get("v.recordId")
        });
        editRecordEvent.fire();
	}
})

Apex Controller:
public class editRecordSimulationController {

    @AuraEnabled
    public static string getTypeFromAccount(string recordId)
    {
        Account acc = [select Type from Account Where Id = :recordId limit 1];
        return acc.Type;
    }
}