Lightning quick action
Apex class
==========
public class AccountController
{
@AuraEnabled
public static List<Contact> displaycons(Id accountId)
{
List<Contact> conlist=[SELECT LastName FROM Contact WHERE AccountId = :accountId];
System.debug('===Conlist size==='+conlist.size());
return conlist;
}
@AuraEnabled
public static List<Opportunity> displayOpptys(Id accId)
{
List<Opportunity> opplist=[select Name from Opportunity where AccountId=:accId];
System.debug('===Opportunity list size==='+opplist.size());
return opplist;
}
}
SpinnerComponent.cmp
====================
<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId"
controller="AccountController" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<div class="slds-form--stacked slds-p-around_medium slds-p-bottom--none">
Page is Loading......
</div>
</aura:component>
controller
==========
({
doInit:function(component,event,helper)
{
helper.navigateToHelper(component,event,helper);
}
})
helper
======
({
navigateToHelper : function(component, event, helper)
{
var evt = $A.get("e.force:navigateToComponent");
evt.setParams
({
componentDef : "c:ContactComp45",
componentAttributes:
{
recordId :component.get("v.recordId")
}
});
evt.fire();
}
})
ContactComp45.cmp
=================
<aura:component implements="force:lightningQuickActionWithoutHeader,
force:hasRecordId"
controller="AccountController" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="conlist" type="list"/>
<aura:attribute name="opptylist" type="list"/>
<div align="center">
<aura:if isTrue="{!v.conlist.length!=0}">
<table class="slds-table slds-table_cell-buffer slds-table_bordered" style="width:29%;">
<lightning:icon iconName="standard:contact" />
Contacts:<b>({!v.conlist.length})</b>
<tr>
<td><b>Name</b></td>
</tr>
<aura:iteration items="{!v.conlist}" var="Items">
<tr>
<td>{!Items.LastName}</td>
</tr>
</aura:iteration>
</table>
</aura:if>
<aura:if isTrue="{!v.opptylist.length!=0}">
<table class="slds-table slds-table_cell-buffer slds-table_bordered" style="width:29%;">
<lightning:icon iconName="standard:opportunity" />
Opportunities:<b>({!v.opptylist.length})</b>
<tr>
<td><b>Name</b></td>
</tr>
<aura:iteration items="{!v.opptylist}" var="Items">
<tr>
<td>{!Items.Name}</td>
</tr>
</aura:iteration>
</table>
</aura:if>
</div>
</aura:component>
controller
==========
({
doInit : function(component, event, helper)
{
helper.fetchContacts(component,event,helper);
helper.fetchoppts(component,event,helper);
}
})
helper
======
({
fetchContacts : function(component,event,helper)
{
var action = component.get("c.displaycons");
action.setParams({
"accountId": component.get("v.recordId")
});
action.setCallback(this, function(response) {
var state = response.getState();
if(state === "SUCCESS")
{
component.set("v.conlist", response.getReturnValue());
}
else
{
console.log('Error in fetching the data');
}
});
$A.enqueueAction(action);
},
fetchoppts :function(component,event,helper)
{
var action = component.get("c.displayOpptys");
action.setParams({
"accId": component.get("v.recordId")
});
action.setCallback(this, function(response) {
var state = response.getState();
if(state === "SUCCESS")
{
component.set("v.opptylist", response.getReturnValue());
} else {
console.log('Error in fetching the data');
}
});
$A.enqueueAction(action);
}
})
==========
public class AccountController
{
@AuraEnabled
public static List<Contact> displaycons(Id accountId)
{
List<Contact> conlist=[SELECT LastName FROM Contact WHERE AccountId = :accountId];
System.debug('===Conlist size==='+conlist.size());
return conlist;
}
@AuraEnabled
public static List<Opportunity> displayOpptys(Id accId)
{
List<Opportunity> opplist=[select Name from Opportunity where AccountId=:accId];
System.debug('===Opportunity list size==='+opplist.size());
return opplist;
}
}
SpinnerComponent.cmp
====================
<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId"
controller="AccountController" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<div class="slds-form--stacked slds-p-around_medium slds-p-bottom--none">
Page is Loading......
</div>
</aura:component>
controller
==========
({
doInit:function(component,event,helper)
{
helper.navigateToHelper(component,event,helper);
}
})
helper
======
({
navigateToHelper : function(component, event, helper)
{
var evt = $A.get("e.force:navigateToComponent");
evt.setParams
({
componentDef : "c:ContactComp45",
componentAttributes:
{
recordId :component.get("v.recordId")
}
});
evt.fire();
}
})
ContactComp45.cmp
=================
<aura:component implements="force:lightningQuickActionWithoutHeader,
force:hasRecordId"
controller="AccountController" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="conlist" type="list"/>
<aura:attribute name="opptylist" type="list"/>
<div align="center">
<aura:if isTrue="{!v.conlist.length!=0}">
<table class="slds-table slds-table_cell-buffer slds-table_bordered" style="width:29%;">
<lightning:icon iconName="standard:contact" />
Contacts:<b>({!v.conlist.length})</b>
<tr>
<td><b>Name</b></td>
</tr>
<aura:iteration items="{!v.conlist}" var="Items">
<tr>
<td>{!Items.LastName}</td>
</tr>
</aura:iteration>
</table>
</aura:if>
<aura:if isTrue="{!v.opptylist.length!=0}">
<table class="slds-table slds-table_cell-buffer slds-table_bordered" style="width:29%;">
<lightning:icon iconName="standard:opportunity" />
Opportunities:<b>({!v.opptylist.length})</b>
<tr>
<td><b>Name</b></td>
</tr>
<aura:iteration items="{!v.opptylist}" var="Items">
<tr>
<td>{!Items.Name}</td>
</tr>
</aura:iteration>
</table>
</aura:if>
</div>
</aura:component>
controller
==========
({
doInit : function(component, event, helper)
{
helper.fetchContacts(component,event,helper);
helper.fetchoppts(component,event,helper);
}
})
helper
======
({
fetchContacts : function(component,event,helper)
{
var action = component.get("c.displaycons");
action.setParams({
"accountId": component.get("v.recordId")
});
action.setCallback(this, function(response) {
var state = response.getState();
if(state === "SUCCESS")
{
component.set("v.conlist", response.getReturnValue());
}
else
{
console.log('Error in fetching the data');
}
});
$A.enqueueAction(action);
},
fetchoppts :function(component,event,helper)
{
var action = component.get("c.displayOpptys");
action.setParams({
"accId": component.get("v.recordId")
});
action.setCallback(this, function(response) {
var state = response.getState();
if(state === "SUCCESS")
{
component.set("v.opptylist", response.getReturnValue());
} else {
console.log('Error in fetching the data');
}
});
$A.enqueueAction(action);
}
})
Therefore, people take more period online.
ReplyDelete