0

i am trying to show a object field in edit mode in lightning component. for that i have written a lightning component and invoking this from a quick action but i am getting the run time exception as org.auraframework.throwable.AuraRuntimeException: Error Retrieving Field for: v.bam1.name my code is as below.. Lightning component:

<aura:component implements="force:lightningQuickAction,force:hasRecordId" controller="BamEditController">   
    <aura:attribute name="bam1" type="TR_Bank_Account_Master__c" default="{'sObjectType': 'TR_Bank_Account_Master__c'}"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInIt}"/>
    <apex:form>
        <force:inputfield value="{!v.bam1.name}"/>
    </apex:form> 
</aura:component>

JS Controller:

({
    doInit : function(component, event, helper) {
        var action =component.get("c.getBanks");

        action.setParams({"bamId": component.get("v.recordId")});

        action.setCallBack(this, function(response){
            var state =  response.getState();
            if(state=== "SUCCESS"){
                component.set("v.bamId",response.getReturnValue());
                console.log(response.getReturnValue());
            }
        }
                          );
        $A.enqueueAction(action);
    }
})

Apex controller:

public class BamEditController {
@auraEnabled
    public static TR_Bank_Account_Master__c getBanks( ID bamId){
        system.debug('prasad id:'+bamId);
        TR_Bank_Account_Master__c bams;
        if(bamId !=null){
       // id bamID= ApexPages.currentPage().getParameters().get('id');
        bams = [select id, name,A_C_Status__c,A_C_Number__c,Bank_Name_Familly__c,Bank_Name_Local__c from TR_Bank_Account_Master__c where id =: bamId LIMIT 1];      
        }
        return bams;

    }
} 

Please correct me where i am wrong..., Thanks

2
  • is N in capital for Name? Lightning is case sensitive. It wants fields names as it is stored in database. {!v.bam1.Name} Feb 28, 2018 at 12:53
  • yes @PranayJaiswal it is 'N' only, but i tried by updating to capital N, No luck same error popped up again:( Feb 28, 2018 at 13:09

1 Answer 1

4

Your problem is here, though you'd be forgiven if you don't see it at first:

<aura:attribute name="bam1" 
    type="TR_Bank_Account_Master__c" 
    default="{'sObjectType': 'TR_Bank_Account_Master__c'}"/>

Lightning is case-sensitive, so you have a case-sensitive problem here; a record's type should be sobjectType, not sObjectType:

<aura:attribute name="bam1" 
    type="TR_Bank_Account_Master__c" 
    default="{'sobjectType': 'TR_Bank_Account_Master__c'}"/>

Also, as pointed out in the comments:

    <force:inputfield value="{!v.bam1.name}"/>

Would also be an error; you need to observe field capitalization:

    <force:inputfield value="{!v.bam1.Name}"/>

You must log in to answer this question.

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