function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
billing badgebilling badge 

how to pass lightning:inputfield onchange value to apex controller

<aura:attirbute name="LeadObj" type="Lead"/>
<lightning:recordEditForm objectApiName="Lead" >
    <lightning:inputField aura:id="accid" fieldName="Account__c" value="{!v.LeadObj.Account__c}" label="Attribute" onchange="{!c.myChangeAcc}"/>


var acc=component.find('accid').get('v.value');
var action = component.get("c.LeadAccountInfo");



apex class:

    public static string LeadAccountInfo(Id ldvalue){
Account ac=[select id,Name from Account where Id =:ldvalue limit 1];
        return ac.Name;

Hi All ,here in thee above acode it is not passing parameter to apex class. if i test with harcoded id its working 

can anyone help

Billing Badge
I believe you get the data in JS controller, So now call the apex we follow
var action  = component.get("c.LeadAccountInfo");
                "Idvalue" : acc
        action.setCallback(this, function(response){
            var status = response.getState();
            if(status === "SUCCESS"){
               console.log( response.getReturnValue() );

If this answer helps you, please mark it as accepted.

Tushar Sharma
billing badgebilling badge
Thanks for the response thanu sharma
its not working stil
Are you getting value in JS controller? Did you get any exception/error? Can you explain what is not working here?
billing badgebilling badge
am getting exception below
Error message: Value provided is invalid for action parameter 'ldvalue' of type 'Id'
try to change Id to type String. Or what you are getting in alert(acc);
Shagufta NooriShagufta Noori
As I am using Blogger for hosting my blog so I am not having this issue.
For Latest  हिंदी में सरकारी नौकरी तथा सरकारी योजनाएं (
Idvalue should be of type String

@AuraEnabled public static string LeadAccountInfo(String ldvalue)
Account ac=[select id,Name from Account where Id =:ldvalue limit 1];
return ac.Name;

Thanks Yogesh