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

Serious help needed with some code that fixes an issue!
Hi all I really hope someone can help me here
I should start by saying I am learning to code but nowhere near ready, I have passed my admin and app builder certifications but actual proper coding is out of my reach. I made my first trigger the other day, which I was proud of!
Anyhow, I have a bit of an issue. My work (a primary school) paid for a customized system which I inherited and basically it works great apart from one part. This one part is a process that generates sessions for attendance processes. The error was known about at the time and I got given a line of code plus a script which I am meant to run that fixes it in within the developer window. Now the person that wrote it has gone, off the face of the planet. Now we run this yearly only and last year it worked. I have the code here. The issue is that the first line of code works I believe.

The code I was given which is not working is here.
Any chance someone can help me make this work? It would be a huge help. Its just me here at the school and this will fix our entire attendance system.
I can send whoever can help E-beers or E-high fives, whatever you need!
I should start by saying I am learning to code but nowhere near ready, I have passed my admin and app builder certifications but actual proper coding is out of my reach. I made my first trigger the other day, which I was proud of!
Anyhow, I have a bit of an issue. My work (a primary school) paid for a customized system which I inherited and basically it works great apart from one part. This one part is a process that generates sessions for attendance processes. The error was known about at the time and I got given a line of code plus a script which I am meant to run that fixes it in within the developer window. Now the person that wrote it has gone, off the face of the planet. Now we run this yearly only and last year it worked. I have the code here. The issue is that the first line of code works I believe.
Student_Section_Utils.studentSection_AfterInsert([select id, Section__c from Student_Section__c where Section__r.RecordType.Name = 'Schedule Group']);Its this code that doesn't work as it brings up this error: Too many DML rows: 10001. I have no idea what this means.
The code I was given which is not working is here.
List<Section_ReportingPeriod__c> srpList = [select id, Scheduler_ReferenceId__c, Section__r.School__c, Section__r.Schedule_Group__c, Section__r.Course__c, Time__c from Section_ReportingPeriod__c where Scheduler_ReferenceId__c = null]; Set<String> SchedSecIDs = new Set<String>(); for(Section_ReportingPeriod__c srp:srpList){ srp.Scheduler_ReferenceId__c = srp.Section__r.School__c+'-'+srp.Section__r.Schedule_Group__c+'-'+srp.Section__r.Course__c+'-'+srp.Time__c; SchedSecIDs.add(srp.Scheduler_ReferenceId__c); } update srpList; List<Scheduled_Section__c> schedSecList = [select id, Needs_Publish__c from Scheduled_Section__c where Section_Reference_Id__c IN:SchedSecIDs]; for(Scheduled_Section__c ss:schedSecList){ ss.Needs_Publish__c = true; } update schedSecList;
Any chance someone can help me make this work? It would be a huge help. Its just me here at the school and this will fix our entire attendance system.
I can send whoever can help E-beers or E-high fives, whatever you need!
save the below class
and open the developer console
use below code to excute
Howp this will help you
Thanks
karthik
All Answers
As your error indicates, you are only allowed to insert, update, delete, etc 10,000 rows per transaction. One way to break these records up into smaller, more managable transactions is to createa a batchable class that handles the deletes in batches of up to 2000 records at a time. For instance, see the following document and the "deleting records"
For Example: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm
if you wanna try try to excute below code in Developer console.
SOQL Select Query allow only 10000 per transaction: Try to create a Batch apex class and update the same thing
Hope this will help you.
Thanks
Karthik
With regards to the code you have sent me, where do I add this in my original code?
Thanks once again!
can you post your full code so that i can create a batch class..
Thanks
karthik
OK well the code is actually in the post above. This is what I was told to do.
1. Copy paste this short code into the developer console:
Then after that I had to copy and paste this script into the developer console:
If this code doesn't fix the problem, I am meant to run this code below after which also has the same DML error so having this fixed would also be amazing:
Thats all the code! Thanks so much for your help, its really appreciated!!!
save the below class
and open the developer console
use below code to excute
Howp this will help you
Thanks
karthik
Amazing you did this