You need to sign in to do that
Don't have an account?
iaesteman
Create bunch of records with apex for a specific month and time to be updated from 6am to 6pm every 5 minutes.
Hello,
I am trying to test the time that will be needed to be created more than 90000 records in salesforce with apex code. I need this so i can prove my boss that this is not a best way to run things.
Why we need this?
We basically want to create available time frames for every course so that people can book a time and play on that course.
For example for one day the available time is from 6am to 6pm and every 5 minutes i need to create records to create those time frames.
More into details:
1 day has 12 hours(6am to 6pm) in 1 hour there are 12 records so for 1 day i will need to create 144 records with this apex code and i need to do that for a specific month(lets say June 2019). Total: 144 x 31 = 4464 records.
This is my code that I did so far and run into developer console and i defintiely need improvments if anyone can help i will be eternaly grateful!
Thanks,
Darko
I am trying to test the time that will be needed to be created more than 90000 records in salesforce with apex code. I need this so i can prove my boss that this is not a best way to run things.
Why we need this?
We basically want to create available time frames for every course so that people can book a time and play on that course.
For example for one day the available time is from 6am to 6pm and every 5 minutes i need to create records to create those time frames.
More into details:
1 day has 12 hours(6am to 6pm) in 1 hour there are 12 records so for 1 day i will need to create 144 records with this apex code and i need to do that for a specific month(lets say June 2019). Total: 144 x 31 = 4464 records.
This is my code that I did so far and run into developer console and i defintiely need improvments if anyone can help i will be eternaly grateful!
List<Courses__c> course =[select id from courses__c]; List<Available_Time__c> cList = new List<Available_Time__c>(); for(Courses__c i: course){ for(Integer j=0;i<2;i++){ Available_Time__c cust = new Available_Time__c(); cust.Course__c = 'a0C0D000000Q7qbUAC'; } } insert cList;
Thanks,
Darko
To create a bunch of records with a specific time you probably need to use Schedulable class, so here the code.
Class (Here only left filter the SOQL with the time to not create more course with the other times) And the Test Class
If you need more about Schedule Class see this trailhead (https://trailhead.salesforce.com/en/content/learn/modules/asynchronous_apex/async_apex_scheduled#). And other option you could use Workflows or Process Builders to avoid use code.
Regards!