Hi here is the sample for code realted to your requrement :
public class OpportunitybyOwnerbasedontotal{
@AuraEnabled
public static List<aggregateResult> getopps() {
return [SELECT Owner.name namee, Owner.Id oId, Sum(Amount) Totalsum, COUNT(Id) Total FROM Opportunity GROUP BY Owner.name,Owner.Id];
}
@AuraEnabled
public static List<Opportunity> getOpportunityRecords(string ownerId) {
return new List<Opportunity>([Select id,Name,Owner.name,Stagename,CloseDate from Opportunity Where OwnerId =: ownerId LIMIT 100]);
}
}
({
myAction : function(component, event, helper) {
var action =component.get("c.getopps");
console.log('The action value is: '+action);
action.setCallback(this, function(a){
component.set("v.opportunities", a.getReturnValue());
// console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
});
$A.enqueueAction(action);
},
Clicked : function(component, event, helper){
var ctarget = event.getSource().get("v.title");
console.log(ctarget);
var action = component.get("c.getOpportunityRecords");
action.setParams({ ownerId : ctarget});
action.setCallback(this, function(response) {
var state = response.getState(); //Checking response status
console.log("opportunities... "+JSON.stringify(response.getReturnValue()));
if (component.isValid() && state === "SUCCESS")
component.set("v.opportunitiesbByowner", response.getReturnValue()); // Adding values in Aura attribute variable.
});
$A.enqueueAction(action);
}
})
i hope it helps you. Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others thanks http://sfdcmonkey.com
LC : JS i hope it helps you.
Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks
http://sfdcmonkey.com