Tuesday, 14 February 2017

Convert Salesforce object returned from Apex controller in lighting component js file into Key,Value pair

          
             
Below code details How to Convert Salesforce object returned from Apex controller into lighting component js file into Key,Value pair


       var clVar = response.getReturnValue();
                         
             var out = Object.keys(clVar).map(function(data){
                 console.log('Value of Data : ' + data);
                 if(data == "ComfortLevel"){                    
                    
                     component.set("v.comfortLevel",response.getReturnValue().ComfortLevel);
                    
                 }else if(data == "CallInter"){
                    
                                component.set("v.callInter",clVar(data));                    
                 }
                
                
                 return [data,clVar[data]];
             });
            
            
             console.log('Complete Output' + out);

             

In the above code Data is the Key/Field value returned from apex controller.
clVar(data)  - Will return the value of the field

No comments:

Post a Comment