0

I have an Aura component and Im trying to retrieve the selected account id of this record edit form:

<lightning:recordEditForm objectApiName="Order">
    <lightning:inputField aura:id="input_field" fieldName="AccountId" required="true" onchange="{!c.handleAccountSubmit}"/>                      
</lightning:recordEditForm>

enter image description here is it possible?

2 Answers 2

0

The change event passes back an array of ids, so it looks something like this:

   ({
        handleAccountSubmit: function (cmp, event, helper) {
        var tempsessionid = event.getParams().value;
        if (tempsessionid) {
            console.log(tempsessionid[0]);
        }
    }
})
5
  • thanks for the reply but ive tried to edit that to match aura's syntax and had no success Commented Nov 13, 2020 at 15:06
  • Can you post the handler code so other folks can take a look? Commented Nov 13, 2020 at 15:18
  • tanks for you question, but the handler is not really important here I just want to use the record id of the selected value to insert an object so the way you are going to use to retrieve it doesnt really matter too much, you see? Commented Nov 13, 2020 at 15:59
  • The updated answer works for me Commented Nov 13, 2020 at 16:41
  • yeah, this answer now is what I wanted, thanks!!! Commented Nov 16, 2020 at 8:40
0

It should be available as the value attribute in the input field component. In this case you could do.

var accountId = component.find('input_field').get('v.value')

Or you can bind the value attribute too:

<lightning:recordEditForm objectApiName="Order">
    <lightning:inputField 
        aura:id="input_field" 
        fieldName="AccountId" 
        required="true" 
        value="{!v.accountId}"
    />                      
</lightning:recordEditForm>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .