function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Max_gMax_g 

Trying to update or iinsert quota records INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY

I have a trigger that is working in the sandbox to insert the Forecast-quota records from my custom budget object.  When I attempted to run in production today, I am getting the above message.  I am running as admin in both environments.  The only difference is the volume of data I am loading.  Any suggestions?

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Max_gMax_g

Here is the trigger I am using. 

 

Proved to be a user that did not have allow forecasting that had to be changed.

 

Error from debug log is Insert failed. First exception on row 45; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []

 

trigger CreateQuota on Start_Budget__c (after update) {
	//Limit the size of list by using Sets which do not contain duplicate elements  
start_Budget__c sb = [select Update_Quota__c from Start_Budget__c limit 1];
system.debug('SB Update Quota = ' + sb.Update_Quota__c);
If (sb.Update_Quota__c == true){ 
	string YearOfToday = String.valueOf(Date.today().year());
	string havequota = 'YES';
	
	string QuotaDate = YearofToday + '-01' + '-01';
	date StDate = date.valueOf(Quotadate);
	
	string QuotaDate2 = YearofToday + '-02' + '-01';
	date StDate2 = date.valueOf(Quotadate2);
	
	string QuotaDate3 = YearofToday + '-03' + '-01';
	date StDate3 = date.valueOf(Quotadate3);
	 	
	string QuotaDate4 = YearofToday + '-04' + '-01';
	date StDate4 = date.valueOf(Quotadate4);
	 	
	string QuotaDate5 = YearofToday + '-05' + '-01';
	date StDate5 = date.valueOf(Quotadate5);
	 	
	string QuotaDate6 = YearofToday + '-06' + '-01';
	date StDate6 = date.valueOf(Quotadate6);
	 	
	string QuotaDate7= YearofToday + '-07' + '-01';
	date StDate7 = date.valueOf(Quotadate7);
	 	
	string QuotaDate8 = YearofToday + '-08' + '-01';
	date StDate8 = date.valueOf(Quotadate8);
	 	
	string QuotaDate9 = YearofToday + '-09' + '-01';
	date StDate9 = date.valueOf(Quotadate9);
	 	
	string QuotaDate10 = YearofToday + '-10' + '-01';
	date StDate10 = date.valueOf(Quotadate10);
	 	
	string QuotaDate11 = YearofToday + '-11' + '-01';
	date StDate11 = date.valueOf(Quotadate11);
	 	
	string QuotaDate12 = YearofToday + '-12' + '-01';
	date StDate12 = date.valueOf(Quotadate12);
	 
	id oid;
	
set<id>  Userids = new set<id>();   

for(Start_Budget__c sbp : trigger.new)
  {  
  	list <User> p = [Select Id, Profile_Prefix__c, isactive from user where Profile_Prefix__c = 'Sale' and isactive = true];
  	system.debug('P = ' + p);
  	for (Integer i=0; i<p.size(); i++) {
  	if(p[i].Id != null)    
    UserIds.add(p[i].Id);  
  	}    
  } 
//Map will contain one User Id to one sum value  
system.debug('Userids = ' + Userids);
system.debug('Userid size = ' + userids.size());
map<id,decimal> UserMap = new map<id,decimal> (); 
map<id,decimal> UserMap1 = new map<id,decimal> (); 
map<id,decimal> UserMap2 = new map<id,decimal> (); 
map<id,decimal> UserMap3 = new map<id,decimal> (); 
map<id,decimal> UserMap4 = new map<id,decimal> (); 
map<id,decimal> UserMap5 = new map<id,decimal> (); 
map<id,decimal> UserMap6 = new map<id,decimal> (); 
map<id,decimal> UserMap7 = new map<id,decimal> ();
map<id,decimal> UserMap8 = new map<id,decimal> (); 
map<id,decimal> UserMap9 = new map<id,decimal> (); 
map<id,decimal> UserMap10 = new map<id,decimal> (); 
map<id,decimal> UserMap11 = new map<id,decimal> ();



for(AggregateResult q : [select User__c, 
sum(Jan_Amount__c) JAN, 
sum(Feb_Amount__c)FEB, 
sum(Mar_Amount__c)MAR, 
sum(Apr_Amount__c)APR,
sum(May_Amount__c)MAY, 
sum(June_Amount__c)JUNE, 
sum(July_Amount__c)JULY,
sum(Aug_Amount__c)AUG, 
sum(Sep_Amount__c)SEP, 
sum(Oct_Amount__c)OCT,
sum(Nov_Amount__c)NOV, 
sum(Dec_Amount__c)DEC
 
 from Budget__c where User__c IN :UserIds and text_year__c =: YearofToday group by rollup(User__c) order by User__c])
{   
	
system.debug('Q = ' + q);

   
  UserMap.put((Id)q.get('User__c'),(decimal)q.get('JAN')); 
  UserMap1.put((Id)q.get('User__C'),(decimal)q.get('FEB'));
  UserMap2.put((Id)q.get('User__c'),(decimal)q.get('MAR'));
  UserMap3.put((Id)q.get('User__c'),(decimal)q.get('APR')); 
  UserMap4.put((Id)q.get('User__c'),(decimal)q.get('MAY')); 
  UserMap5.put((Id)q.get('User__C'),(decimal)q.get('JUNE'));
  UserMap6.put((Id)q.get('User__c'),(decimal)q.get('JULY'));
  UserMap7.put((Id)q.get('User__c'),(decimal)q.get('AUG'));
  UserMap8.put((Id)q.get('User__c'),(decimal)q.get('SEP')); 
  UserMap9.put((Id)q.get('User__C'),(decimal)q.get('OCT'));
  UserMap10.put((Id)q.get('User__c'),(decimal)q.get('NOV'));
  UserMap11.put((Id)q.get('User__c'),(decimal)q.get('DEC'));
  
  
} 
 system.debug('UserMAp = ' +Usermap);
  system.debug('Have Quota Value = ' + havequota);
  List<ForecastingQuota> UsersToUpdate = new List<ForecastingQuota>(); 
  List<ForecastingQuota> UsersToUpdate2 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate3 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate4 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate5 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate6 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate7 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate8 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate9 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate10 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate11 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate12 = new List<ForecastingQuota>();
 Budget__c[] o = [Select User__c, Account_Owner__c  from Budget__c where User__c IN :UserIds and text_Year__c =: YearofToday order by User__c];
    system.debug('Budget size = ' + o.size()); 
  	for (Integer i=0; i<o.size(); i++) {
  		system.debug('O user ' + i + '= ' + o[i].user__c);
  	IF (o[i].User__c != oid){
  		 
  
  	ForecastingQuota fcq = new ForecastingQuota(); 
  	ForecastingQuota fcq2 = new ForecastingQuota();
  	ForecastingQuota fcq3 = new ForecastingQuota();
  	ForecastingQuota fcq4 = new ForecastingQuota();
  	ForecastingQuota fcq5 = new ForecastingQuota();
  	ForecastingQuota fcq6 = new ForecastingQuota();
  	ForecastingQuota fcq7 = new ForecastingQuota();
  	ForecastingQuota fcq8 = new ForecastingQuota();
  	ForecastingQuota fcq9 = new ForecastingQuota();
  	ForecastingQuota fcq10 = new ForecastingQuota();
  	ForecastingQuota fcq11 = new ForecastingQuota();
  	ForecastingQuota fcq12 = new ForecastingQuota();
     Decimal PaymentSum = UserMap.get(o[i].User__c);
     Decimal PaymentSum2 = UserMap1.get(o[i].User__c);
     Decimal PaymentSum3 = UserMap2.get(o[i].User__c);
     Decimal PaymentSum4 = UserMap3.get(o[i].User__c);
     Decimal PaymentSum5 = UserMap4.get(o[i].User__c);
     Decimal PaymentSum6 = UserMap5.get(o[i].User__c);
     Decimal PaymentSum7 = UserMap6.get(o[i].User__c);
     Decimal PaymentSum8 = UserMap7.get(o[i].User__c);
     Decimal PaymentSum9 = UserMap8.get(o[i].User__c);
     Decimal PaymentSum10 = UserMap9.get(o[i].User__c);
     Decimal PaymentSum11 = UserMap10.get(o[i].User__c);
     Decimal PaymentSum12 = UserMap11.get(o[i].User__c);
     
          
     fcq.Quotaamount = 0;  
     fcq.QuotaOwnerId = o[i].User__c;  
     fcq.Quotaamount = PaymentSum;
     fcq.StartDate = date.valueOf(Quotadate);
     UsersToUpdate.add(fcq);  
     
     fcq2.Quotaamount = 0;
     fcq2.QuotaOwnerId = o[i].User__c;
     fcq2.Quotaamount = PaymentSum2;
     fcq2.StartDate = date.valueOf(Quotadate2);
     UsersToUpdate2.add(fcq2);
     
     fcq3.Quotaamount = 0;  
     fcq3.QuotaOwnerId = o[i].User__c;
     fcq3.Quotaamount = PaymentSum3;
     fcq3.StartDate = date.valueOf(Quotadate3);
     UsersToUpdate3.add(fcq3);  
     
     fcq4.Quotaamount = 0;
     fcq4.QuotaOwnerId = o[i].User__c;
     fcq4.Quotaamount = PaymentSum4;
     fcq4.StartDate = date.valueOf(Quotadate4);
     UsersToUpdate4.add(fcq4); 
     
     fcq5.Quotaamount = 0; 
     fcq5.QuotaOwnerId = o[i].User__c;
     fcq5.Quotaamount = PaymentSum5;
     fcq5.StartDate = date.valueOf(Quotadate5);
     UsersToUpdate5.add(fcq5);  
     
     fcq6.Quotaamount = 0;
     fcq6.QuotaOwnerId = o[i].User__c;
     fcq6.Quotaamount = PaymentSum6;
     fcq6.StartDate = date.valueOf(Quotadate6);
     UsersToUpdate6.add(fcq6);  
     
     fcq7.Quotaamount = 0;
     fcq7.QuotaOwnerId = o[i].User__c;
     fcq7.Quotaamount = PaymentSum7;
     fcq7.StartDate = date.valueOf(Quotadate7);
     UsersToUpdate7.add(fcq7);  
     
     fcq8.Quotaamount = 0;
     fcq8.QuotaOwnerId = o[i].User__c;
     fcq8.Quotaamount = PaymentSum8;
     fcq8.StartDate = date.valueOf(Quotadate8);
     UsersToUpdate8.add(fcq8);  
     
     fcq9.Quotaamount = 0;
     fcq9.QuotaOwnerId = o[i].User__c;
     fcq9.Quotaamount = PaymentSum9;
     fcq9.StartDate = date.valueOf(Quotadate9);
     UsersToUpdate9.add(fcq9);  
     
     fcq10.Quotaamount = 0;
     fcq10.QuotaOwnerId = o[i].User__c;
     fcq10.Quotaamount = PaymentSum10;
     fcq10.StartDate = date.valueOf(Quotadate10);
     UsersToUpdate10.add(fcq10);  
     
     fcq11.Quotaamount = 0;
     fcq11.QuotaOwnerId = o[i].User__c;
     fcq11.Quotaamount = PaymentSum11;
     fcq11.StartDate = date.valueOf(Quotadate11);
     UsersToUpdate11.add(fcq11);  
     
     fcq12.Quotaamount = 0;
     fcq12.QuotaOwnerId = o[i].User__c;
     fcq12.Quotaamount = PaymentSum12;
     fcq12.StartDate = date.valueOf(Quotadate12);
     UsersToUpdate12.add(fcq12);  
        
  } 
  oid = o[i].User__c;
  }
   try{
   Insert UsersToUpdate;
   Insert UsersToUpdate2;
   Insert UsersToUpdate3;
   Insert UsersToUpdate4;
   Insert UsersToUpdate5;
   Insert UsersToUpdate6;
   Insert UsersToUpdate7;
   Insert UsersToUpdate8;
   Insert UsersToUpdate9;
   Insert UsersToUpdate10;
   Insert UsersToUpdate11;
   Insert UsersToUpdate12;
   }
  catch(Exception e){
  }
  
 sb.Update_Quota__c = false;
 system.debug('CreateQuota = ' + sb.Update_Quota__c);
 update sb; 
}

}

 

All Answers

jbroquistjbroquist
The error is basically saying you don't have access to one of the records you are trying to relate your budget record to. If you post your trigger and unit test code it would be a lot easier to troubleshoot your issue.
Max_gMax_g

Here is the trigger I am using. 

 

Proved to be a user that did not have allow forecasting that had to be changed.

 

Error from debug log is Insert failed. First exception on row 45; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []

 

trigger CreateQuota on Start_Budget__c (after update) {
	//Limit the size of list by using Sets which do not contain duplicate elements  
start_Budget__c sb = [select Update_Quota__c from Start_Budget__c limit 1];
system.debug('SB Update Quota = ' + sb.Update_Quota__c);
If (sb.Update_Quota__c == true){ 
	string YearOfToday = String.valueOf(Date.today().year());
	string havequota = 'YES';
	
	string QuotaDate = YearofToday + '-01' + '-01';
	date StDate = date.valueOf(Quotadate);
	
	string QuotaDate2 = YearofToday + '-02' + '-01';
	date StDate2 = date.valueOf(Quotadate2);
	
	string QuotaDate3 = YearofToday + '-03' + '-01';
	date StDate3 = date.valueOf(Quotadate3);
	 	
	string QuotaDate4 = YearofToday + '-04' + '-01';
	date StDate4 = date.valueOf(Quotadate4);
	 	
	string QuotaDate5 = YearofToday + '-05' + '-01';
	date StDate5 = date.valueOf(Quotadate5);
	 	
	string QuotaDate6 = YearofToday + '-06' + '-01';
	date StDate6 = date.valueOf(Quotadate6);
	 	
	string QuotaDate7= YearofToday + '-07' + '-01';
	date StDate7 = date.valueOf(Quotadate7);
	 	
	string QuotaDate8 = YearofToday + '-08' + '-01';
	date StDate8 = date.valueOf(Quotadate8);
	 	
	string QuotaDate9 = YearofToday + '-09' + '-01';
	date StDate9 = date.valueOf(Quotadate9);
	 	
	string QuotaDate10 = YearofToday + '-10' + '-01';
	date StDate10 = date.valueOf(Quotadate10);
	 	
	string QuotaDate11 = YearofToday + '-11' + '-01';
	date StDate11 = date.valueOf(Quotadate11);
	 	
	string QuotaDate12 = YearofToday + '-12' + '-01';
	date StDate12 = date.valueOf(Quotadate12);
	 
	id oid;
	
set<id>  Userids = new set<id>();   

for(Start_Budget__c sbp : trigger.new)
  {  
  	list <User> p = [Select Id, Profile_Prefix__c, isactive from user where Profile_Prefix__c = 'Sale' and isactive = true];
  	system.debug('P = ' + p);
  	for (Integer i=0; i<p.size(); i++) {
  	if(p[i].Id != null)    
    UserIds.add(p[i].Id);  
  	}    
  } 
//Map will contain one User Id to one sum value  
system.debug('Userids = ' + Userids);
system.debug('Userid size = ' + userids.size());
map<id,decimal> UserMap = new map<id,decimal> (); 
map<id,decimal> UserMap1 = new map<id,decimal> (); 
map<id,decimal> UserMap2 = new map<id,decimal> (); 
map<id,decimal> UserMap3 = new map<id,decimal> (); 
map<id,decimal> UserMap4 = new map<id,decimal> (); 
map<id,decimal> UserMap5 = new map<id,decimal> (); 
map<id,decimal> UserMap6 = new map<id,decimal> (); 
map<id,decimal> UserMap7 = new map<id,decimal> ();
map<id,decimal> UserMap8 = new map<id,decimal> (); 
map<id,decimal> UserMap9 = new map<id,decimal> (); 
map<id,decimal> UserMap10 = new map<id,decimal> (); 
map<id,decimal> UserMap11 = new map<id,decimal> ();



for(AggregateResult q : [select User__c, 
sum(Jan_Amount__c) JAN, 
sum(Feb_Amount__c)FEB, 
sum(Mar_Amount__c)MAR, 
sum(Apr_Amount__c)APR,
sum(May_Amount__c)MAY, 
sum(June_Amount__c)JUNE, 
sum(July_Amount__c)JULY,
sum(Aug_Amount__c)AUG, 
sum(Sep_Amount__c)SEP, 
sum(Oct_Amount__c)OCT,
sum(Nov_Amount__c)NOV, 
sum(Dec_Amount__c)DEC
 
 from Budget__c where User__c IN :UserIds and text_year__c =: YearofToday group by rollup(User__c) order by User__c])
{   
	
system.debug('Q = ' + q);

   
  UserMap.put((Id)q.get('User__c'),(decimal)q.get('JAN')); 
  UserMap1.put((Id)q.get('User__C'),(decimal)q.get('FEB'));
  UserMap2.put((Id)q.get('User__c'),(decimal)q.get('MAR'));
  UserMap3.put((Id)q.get('User__c'),(decimal)q.get('APR')); 
  UserMap4.put((Id)q.get('User__c'),(decimal)q.get('MAY')); 
  UserMap5.put((Id)q.get('User__C'),(decimal)q.get('JUNE'));
  UserMap6.put((Id)q.get('User__c'),(decimal)q.get('JULY'));
  UserMap7.put((Id)q.get('User__c'),(decimal)q.get('AUG'));
  UserMap8.put((Id)q.get('User__c'),(decimal)q.get('SEP')); 
  UserMap9.put((Id)q.get('User__C'),(decimal)q.get('OCT'));
  UserMap10.put((Id)q.get('User__c'),(decimal)q.get('NOV'));
  UserMap11.put((Id)q.get('User__c'),(decimal)q.get('DEC'));
  
  
} 
 system.debug('UserMAp = ' +Usermap);
  system.debug('Have Quota Value = ' + havequota);
  List<ForecastingQuota> UsersToUpdate = new List<ForecastingQuota>(); 
  List<ForecastingQuota> UsersToUpdate2 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate3 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate4 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate5 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate6 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate7 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate8 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate9 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate10 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate11 = new List<ForecastingQuota>();
  List<ForecastingQuota> UsersToUpdate12 = new List<ForecastingQuota>();
 Budget__c[] o = [Select User__c, Account_Owner__c  from Budget__c where User__c IN :UserIds and text_Year__c =: YearofToday order by User__c];
    system.debug('Budget size = ' + o.size()); 
  	for (Integer i=0; i<o.size(); i++) {
  		system.debug('O user ' + i + '= ' + o[i].user__c);
  	IF (o[i].User__c != oid){
  		 
  
  	ForecastingQuota fcq = new ForecastingQuota(); 
  	ForecastingQuota fcq2 = new ForecastingQuota();
  	ForecastingQuota fcq3 = new ForecastingQuota();
  	ForecastingQuota fcq4 = new ForecastingQuota();
  	ForecastingQuota fcq5 = new ForecastingQuota();
  	ForecastingQuota fcq6 = new ForecastingQuota();
  	ForecastingQuota fcq7 = new ForecastingQuota();
  	ForecastingQuota fcq8 = new ForecastingQuota();
  	ForecastingQuota fcq9 = new ForecastingQuota();
  	ForecastingQuota fcq10 = new ForecastingQuota();
  	ForecastingQuota fcq11 = new ForecastingQuota();
  	ForecastingQuota fcq12 = new ForecastingQuota();
     Decimal PaymentSum = UserMap.get(o[i].User__c);
     Decimal PaymentSum2 = UserMap1.get(o[i].User__c);
     Decimal PaymentSum3 = UserMap2.get(o[i].User__c);
     Decimal PaymentSum4 = UserMap3.get(o[i].User__c);
     Decimal PaymentSum5 = UserMap4.get(o[i].User__c);
     Decimal PaymentSum6 = UserMap5.get(o[i].User__c);
     Decimal PaymentSum7 = UserMap6.get(o[i].User__c);
     Decimal PaymentSum8 = UserMap7.get(o[i].User__c);
     Decimal PaymentSum9 = UserMap8.get(o[i].User__c);
     Decimal PaymentSum10 = UserMap9.get(o[i].User__c);
     Decimal PaymentSum11 = UserMap10.get(o[i].User__c);
     Decimal PaymentSum12 = UserMap11.get(o[i].User__c);
     
          
     fcq.Quotaamount = 0;  
     fcq.QuotaOwnerId = o[i].User__c;  
     fcq.Quotaamount = PaymentSum;
     fcq.StartDate = date.valueOf(Quotadate);
     UsersToUpdate.add(fcq);  
     
     fcq2.Quotaamount = 0;
     fcq2.QuotaOwnerId = o[i].User__c;
     fcq2.Quotaamount = PaymentSum2;
     fcq2.StartDate = date.valueOf(Quotadate2);
     UsersToUpdate2.add(fcq2);
     
     fcq3.Quotaamount = 0;  
     fcq3.QuotaOwnerId = o[i].User__c;
     fcq3.Quotaamount = PaymentSum3;
     fcq3.StartDate = date.valueOf(Quotadate3);
     UsersToUpdate3.add(fcq3);  
     
     fcq4.Quotaamount = 0;
     fcq4.QuotaOwnerId = o[i].User__c;
     fcq4.Quotaamount = PaymentSum4;
     fcq4.StartDate = date.valueOf(Quotadate4);
     UsersToUpdate4.add(fcq4); 
     
     fcq5.Quotaamount = 0; 
     fcq5.QuotaOwnerId = o[i].User__c;
     fcq5.Quotaamount = PaymentSum5;
     fcq5.StartDate = date.valueOf(Quotadate5);
     UsersToUpdate5.add(fcq5);  
     
     fcq6.Quotaamount = 0;
     fcq6.QuotaOwnerId = o[i].User__c;
     fcq6.Quotaamount = PaymentSum6;
     fcq6.StartDate = date.valueOf(Quotadate6);
     UsersToUpdate6.add(fcq6);  
     
     fcq7.Quotaamount = 0;
     fcq7.QuotaOwnerId = o[i].User__c;
     fcq7.Quotaamount = PaymentSum7;
     fcq7.StartDate = date.valueOf(Quotadate7);
     UsersToUpdate7.add(fcq7);  
     
     fcq8.Quotaamount = 0;
     fcq8.QuotaOwnerId = o[i].User__c;
     fcq8.Quotaamount = PaymentSum8;
     fcq8.StartDate = date.valueOf(Quotadate8);
     UsersToUpdate8.add(fcq8);  
     
     fcq9.Quotaamount = 0;
     fcq9.QuotaOwnerId = o[i].User__c;
     fcq9.Quotaamount = PaymentSum9;
     fcq9.StartDate = date.valueOf(Quotadate9);
     UsersToUpdate9.add(fcq9);  
     
     fcq10.Quotaamount = 0;
     fcq10.QuotaOwnerId = o[i].User__c;
     fcq10.Quotaamount = PaymentSum10;
     fcq10.StartDate = date.valueOf(Quotadate10);
     UsersToUpdate10.add(fcq10);  
     
     fcq11.Quotaamount = 0;
     fcq11.QuotaOwnerId = o[i].User__c;
     fcq11.Quotaamount = PaymentSum11;
     fcq11.StartDate = date.valueOf(Quotadate11);
     UsersToUpdate11.add(fcq11);  
     
     fcq12.Quotaamount = 0;
     fcq12.QuotaOwnerId = o[i].User__c;
     fcq12.Quotaamount = PaymentSum12;
     fcq12.StartDate = date.valueOf(Quotadate12);
     UsersToUpdate12.add(fcq12);  
        
  } 
  oid = o[i].User__c;
  }
   try{
   Insert UsersToUpdate;
   Insert UsersToUpdate2;
   Insert UsersToUpdate3;
   Insert UsersToUpdate4;
   Insert UsersToUpdate5;
   Insert UsersToUpdate6;
   Insert UsersToUpdate7;
   Insert UsersToUpdate8;
   Insert UsersToUpdate9;
   Insert UsersToUpdate10;
   Insert UsersToUpdate11;
   Insert UsersToUpdate12;
   }
  catch(Exception e){
  }
  
 sb.Update_Quota__c = false;
 system.debug('CreateQuota = ' + sb.Update_Quota__c);
 update sb; 
}

}

 

This was selected as the best answer