• Deepak Todkar
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Please let me know how to display it on my aura component as below is m code.

component
-----------------------------




<aura:component controller='AccountContact'>
    <aura:attribute name='accConList' type='Object[]'/>
    
    <aura:handler name='init' value='{!this}' action='{!c.doInit}'/>
   -------- {!v.accConList[0].accRec[0].Name}
    <aura:iteration items='{!v.accConList}' var='accCon'>
        lets see !!!!
         {!accCon.accRec[0].name}&nbsp;
        
    </aura:iteration>
</aura:component>



---------------------

controller.js
-----------------------------------------------------
({
doInit : function(component, event, helper) {
//alert('inside do init');
var action=component.get('c.fetchAccountContact');

action.setCallback(this,function(response){

var state=response.getState();
if(state=='SUCCESS' || state=='DRAFT'){
var returnValue=response.getReturnValue();
console.log('data returned---'+returnValue);
console.log('data returned---'+JSON.stringify(returnValue));
alert('reurt value---'+JSON.stringify(returnValue));
component.set('v.accConList',response.getReturnValue());


}

});
$A.enqueueAction(action);
}
})
--------------------------------
apex controller
-----------------------------------------
public class AccountContact{
public static list accList=new list();
public static List accConList{get; set;}

@AuraEnabled
public static List fetchAccountContact()
{
accList=[Select Id,Name,Phone,(select id,lastname from contacts) from Account];
for(integer i=0;i();
accConList.add(new AccConWrap(accList[i],accList[i].Contacts));
}

return accConList;
}

public class AccConWrap{

public Account accRec{get;set;}
public List conRecList{get;set;}

public AccConWrap(Account acc,List con){
accRec=acc;
conRecList=con;
}
}
}
------------------------------------------------
Please let me know how to display it on my aura component as below is m code.

component
-----------------------------




<aura:component controller='AccountContact'>
    <aura:attribute name='accConList' type='Object[]'/>
    
    <aura:handler name='init' value='{!this}' action='{!c.doInit}'/>
   -------- {!v.accConList[0].accRec[0].Name}
    <aura:iteration items='{!v.accConList}' var='accCon'>
        lets see !!!!
         {!accCon.accRec[0].name}&nbsp;
        
    </aura:iteration>
</aura:component>



---------------------

controller.js
-----------------------------------------------------
({
doInit : function(component, event, helper) {
//alert('inside do init');
var action=component.get('c.fetchAccountContact');

action.setCallback(this,function(response){

var state=response.getState();
if(state=='SUCCESS' || state=='DRAFT'){
var returnValue=response.getReturnValue();
console.log('data returned---'+returnValue);
console.log('data returned---'+JSON.stringify(returnValue));
alert('reurt value---'+JSON.stringify(returnValue));
component.set('v.accConList',response.getReturnValue());


}

});
$A.enqueueAction(action);
}
})
--------------------------------
apex controller
-----------------------------------------
public class AccountContact{
public static list accList=new list();
public static List accConList{get; set;}

@AuraEnabled
public static List fetchAccountContact()
{
accList=[Select Id,Name,Phone,(select id,lastname from contacts) from Account];
for(integer i=0;i();
accConList.add(new AccConWrap(accList[i],accList[i].Contacts));
}

return accConList;
}

public class AccConWrap{

public Account accRec{get;set;}
public List conRecList{get;set;}

public AccConWrap(Account acc,List con){
accRec=acc;
conRecList=con;
}
}
}
------------------------------------------------

Hi,
I have created a lightning component which should display/fetch the editable fields of the object from the current record id dynamically.
I added this component to a global action and added the action in the record page layout.
If I place the same button in any object record page it will display the fields dynamically from the current record id using keyprefix of the id.

Below is the image of the fields available in lead object. 

User-added image 
I want this fields to display in a new browser tab with the same record page ID and should happen with other SObject also