+ Start a Discussion
Rama_SFDCRama_SFDC 

getReturnValue .field not working JS controller

Hi ,
help me on this below issue , how to resolve 
      field API name passing from design:attribut to fieldname attribute

       var fields = component.get("v.fieldname");

        console.log('fieldapiname'+fields); // getting field api name

        var action = component.get("c.getimagesresponse");
        
        action.setParams({
            recId: recordId,
            fieldName:fields
        });
        action.setCallback(this, function(a) {
  var sobjectrecord = a.getReturnValue().fields; // Not working 
 console.log('fieldname '+sobjectrecord ); // getting undefined
 var sobjectrecord = a.getReturnValue().No_of_licencess__c ; //hardcoded field API name, when passing field API name returnning correct result 
 console.log('fieldname '+sobjectrecord );  // sucess 

  i want to pass field API name dynamically , how to resolve this issue .
Thanks in Advance 
Balagopal GBalagopal G

Hi ,

check how the response is coming , then try to assign it to sobjectrecord  accordingly.

console.log(a.getReturnValue()) what it gives?!.

regards.