You need to sign in to do that
Don't have an account?

Code ato all opp amount
I have written the below code to update bulk records to add all opportunity amount on quota object. Since it is a bulk record I have used asynchronous bulk update records.
public with sharing class listopponquota {
public list<Opportunity> oppList{get;set;}
public list<quota__c> qutoaList{get;set;}
public set<ID> oppIds = new set<ID>();
public void listopponquota()
{
String selectedVal ='';
oppList = new list<Opportunity>();
qutoaList = new list<quota__c>();
oppList();
}
public pageReference oppList() {
Id qId = (Id) ApexPages.currentPage().getParameters().get('id');
system.debug('Id-->'+qId);
List<quota__c> quotaList1 = new List<quota__c>();
List<Opportunity> oppList1 = new List<Opportunity>();
quotaList1 =[select Id, Name,Start_Date__c,End_Date__c,Assign_to_User__c,Actual_Amount__c, OwnerId from quota__c where Id =: qId Limit 1];
oppList1 = [Select Id, Name, CloseDate, StageName,OwnerId,Amount From Opportunity where StageName = 'Closed Won'];
system.debug('quotaList1-->'+quotaList1);
if(quotaList1.size() > 0){
for(quota__c q : quotaList1){
for(Opportunity opp : oppList1){
system.debug('closedDate-->'+opp.CloseDate);
if(opp.CloseDate >= q.Start_Date__c && opp.CloseDate <= q.End_Date__c && q.Assign_to_User__c == q.OwnerId){
oppList.add(opp);
oppIds.add(opp.id);
}
}
}
}
for(aggregateresult ag : [SELECT SUM(Amount) sum FROM Opportunity where ID =:oppIds]){
system.debug('oppList-->'+double.valueof(ag.get('SUM')));
for(quota__c q : quotaList1){
if(q.Actual_Amount__c != double.valueof(ag.get('SUM'))){
q.Actual_Amount__c = double.valueof(ag.get('SUM'));
qutoaList.add(q);
}
}
}
system.debug('oppList-->'+oppList.size());
return null;
}
public class FutureClassLimitsTest {
@future(callout=true)
public static void docallouts(){
system.debug('qutoaList-->'+qutoaList.size());
if(qutoaList.size()>0){
update qutoaList;
}
}
}

public with sharing class listopponquota {
public list<Opportunity> oppList{get;set;}
public list<quota__c> qutoaList{get;set;}
public set<ID> oppIds = new set<ID>();
public void listopponquota()
{
String selectedVal ='';
oppList = new list<Opportunity>();
qutoaList = new list<quota__c>();
oppList();
}
public pageReference oppList() {
Id qId = (Id) ApexPages.currentPage().getParameters().get('id');
system.debug('Id-->'+qId);
List<quota__c> quotaList1 = new List<quota__c>();
List<Opportunity> oppList1 = new List<Opportunity>();
quotaList1 =[select Id, Name,Start_Date__c,End_Date__c,Assign_to_User__c,Actual_Amount__c, OwnerId from quota__c where Id =: qId Limit 1];
oppList1 = [Select Id, Name, CloseDate, StageName,OwnerId,Amount From Opportunity where StageName = 'Closed Won'];
system.debug('quotaList1-->'+quotaList1);
if(quotaList1.size() > 0){
for(quota__c q : quotaList1){
for(Opportunity opp : oppList1){
system.debug('closedDate-->'+opp.CloseDate);
if(opp.CloseDate >= q.Start_Date__c && opp.CloseDate <= q.End_Date__c && q.Assign_to_User__c == q.OwnerId){
oppList.add(opp);
oppIds.add(opp.id);
}
}
}
}
for(aggregateresult ag : [SELECT SUM(Amount) sum FROM Opportunity where ID =:oppIds]){
system.debug('oppList-->'+double.valueof(ag.get('SUM')));
for(quota__c q : quotaList1){
if(q.Actual_Amount__c != double.valueof(ag.get('SUM'))){
q.Actual_Amount__c = double.valueof(ag.get('SUM'));
qutoaList.add(q);
}
}
}
system.debug('oppList-->'+oppList.size());
return null;
}
public class FutureClassLimitsTest {
@future(callout=true)
public static void docallouts(){
system.debug('qutoaList-->'+qutoaList.size());
if(qutoaList.size()>0){
update qutoaList;
}
}
}
Change variable qutoaList in line 3 to static variable
Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.
Thanks and Regards
All Answers
Static methods are not allowed inside inner classes.tTry refactoring your code by moving your method docallouts() inside listopponquota class.
Please refer below link which might help you in this
https://salesforce.stackexchange.com/questions/135865/only-top-level-class-methods-can-be-declared-static
Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.
Thanks and Regards
Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.
Thanks and Regards
Change variable qutoaList in line 3 to static variable
Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.
Thanks and Regards
Please verify or check your code before posting your error here.
Your method name is docallouts but your are using docallout in vfpage.That is why you are getting this error.Change method name in vf page.
Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.
Thanks and Regards
Thank you so muck devi code is working fine but inspite of using future meyhord why ma I getting below error