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?

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 Nov 13 '20 at 15:06
  • Can you post the handler code so other folks can take a look? Nov 13 '20 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? Nov 13 '20 at 15:59
  • The updated answer works for me Nov 13 '20 at 16:41
  • yeah, this answer now is what I wanted, thanks!!! Nov 16 '20 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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.