I am easily able to fetch a lookup ID from a inputField
<lightning:recordEditForm
objectApiName="Case">
<!-- the messages component is for error messages -->
<lightning:messages />
<lightning:inputField fieldName="AccountId" onchange="{!c.getAccount}"/>
<lightning:inputField fieldName="Subject" />
<lightning:inputField fieldName="Description" />
<div class="slds-m-top_medium">
<lightning:button disabled="{!v.disabled}" variant="brand" type="submit" name="save" label="Save" />
</div>
</lightning:recordEditForm>
controller.js
({
getAccount : function(cmp, event, helper) {
var accountId = event.getSource().get('v.value')
},
})
However, I am trying to get the name/label of the acount:
My first instict was to try and get the Element, however, due to locker service, a Proxy Object is returned.
console.log(cmp.getElements());
I would have tried to get the textContent, however, I am unable to access the Object.
I know how to workaround this using some other components, referencing the id in it and then fetching the name (for example, in a second lightning:recordEditForm or Force:recordData).
I am trying to achieve this on field chage, not on recordSubmit or any of the other events provided by the form.
Obviously, I dont want to query for the account name from the server using the ID.
Is this doable, if so, what would be considered the best approach? or due to locker service there is no way around this?