Last active
January 30, 2021 19:47
-
-
Save sfcure/0605a5bf66a9a196f354c5102c92423c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:event type="COMPONENT" description="On record selection"> | |
<aura:attribute name="childObjectName" type="String"/> | |
<aura:attribute name="fieldName" type="String"/> | |
<aura:attribute name="selectedRecordId" type="String"/> | |
</aura:event> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component> | |
<aura:attribute name="childObjectName" type="String" required="true"/> | |
<aura:attribute name="fieldName" type="String" required="true"/> | |
<aura:attribute name="selectedRecordId" type="String"/> | |
<aura:registerEvent name="onSelectEvt" type="c:CustomLookupSelectionEvt"/> | |
<lightning:recordEditForm | |
onload="{!c.setSelectedRecordId}" | |
objectApiName="{!v.childObjectName}"> | |
<lightning:inputField aura:id="lookupField" variant="label-stacked" fieldName="{!v.fieldName}" onchange="{!c.fireOnSelectEvt}"/> | |
</lightning:recordEditForm> | |
</aura:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
setSelectedRecordId: function(component, event, helper) { | |
var selectedRecordId = component.get("v.selectedRecordId"); | |
component.find("lookupField").set("v.value", selectedRecordId); | |
}, | |
fireOnSelectEvt : function(component, event, helper) { | |
var cmpEvent = component.getEvent("onSelectEvt"); | |
cmpEvent.setParams({ | |
"childObjectName": component.get("v.childObjectName"), | |
"fieldName": component.get("v.fieldName"), | |
"selectedRecordId": component.find("lookupField").get("v.value") | |
}); | |
cmpEvent.fire(); | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--aura Handler--> | |
<aura:handler name="onSelectEvt" event="c:CustomLookupSelectionEvt" action="{!c.getLookUpValues}"/> | |
<c:CustomLookupStd | |
selectedRecordId="{!v.projectId}" | |
childObjectName="Contact" | |
fieldName="Project_in_Contact__c"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
getLookUpValues : function(component, event, helper){ | |
let fieldName = event.getParam("fieldName"); | |
let projectId = event.getParam("selectedRecordId"); | |
component.set("v.projectId", projectId); | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
works well but how to fetch more than one field from same obj like picklist