You need to sign in to do that
Don't have an account?
Tulasiram Chippala
While loading a record onchangeCalled function is calling by default from onLoad and displaying spinners and all
Error2:
If I change a value on the field it is calling "handleLoad" too and "component.set("v.vendorDetailsFlag", true);" is failing because handleLoad is loading record again.
Please help me on this
Why Onload event is calling onchange event on lightning:inputField
OnLoad function on RecordEditForm: handleLoad : function(component, event, helper){ var record = event.getParams().recordUi.record; console.log("onLoad"); console.log(JSON.parse(JSON.stringify(record))); var obj = JSON.parse(JSON.stringify(record)); console.log('Record Id',obj.id); console.log('Record Id',obj.fields.EmploymentStatus__c.value); var fieldValue = obj.fields.EmploymentStatus__c.value; if(fieldValue === 'C2C'){ component.set("v.vendorDetailsFlag", true); } else { component.set("v.vendorDetailsFlag", false); } }, Onchange Event on InputField: onchangeCalled : function(component, event, helper){ component.set("v.spinnerFlag",true); window.setTimeout( $A.getCallback(function() { var val = event.getSource().get("v.value"); if(val === 'C2C'){ component.set("v.vendorDetailsFlag", true); } else { component.set("v.vendorDetailsFlag", false); } component.set("v.spinnerFlag",false); }), 500 ); },Error1:
While loading a record onchangeCalled function is calling by default from onLoad and displaying spinners and all
Error2:
If I change a value on the field it is calling "handleLoad" too and "component.set("v.vendorDetailsFlag", true);" is failing because handleLoad is loading record again.
<lightning:recordEditForm aura:id="recordViewForm" objectApiName="Candidate" recordId="{!v.recordId}" recordTypeId="" onload="{!c.handleLoad}" onsubmit="{!c.handleSubmit}" onsuccess="{!c.handleSuccess}" >
<lightning:inputfield name="employmentStatus" aura:id="employmentStatus" fieldName="EmploymentStatus__c" onchange="{!c.onchangeCalled}"/>
Please help me on this
Your onchangeCalled funtion is getting called because when your component is getting loaded the value of <lightning:inputField/> is getting changed. As you are passing a record id and that perticular record is having some value in EmploymentStatus__c field.
If you just want to call this method when user is manually giving some value in this field so its better to go for onkeyup or on keypress event instead of onchange.
Thanks,
Nitish