You are here:
Create Consent Records with an Apex Job for Vaccine Eligibility
With a scheduled Apex job, you can regularly create consent records for the leads that are generated from your vaccine eligibility sign-up form. Simply schedule the job, and it runs at the specified time when you have new leads from the sign-up form.
The job uses the schedulable class AsyncConsentRecordCreator to create the consent records for the leads.
Each batch performs these actions on the lead records:
- Fetch Lead records with
WasIndividualCreated__c = false. - If the record has
HasNotificationConsent__c = true:- Create an Individual record.
- Create a Contact Type Consent record.
- Update the lead record with
WasIndividualCreated__c = trueand link it to the Individual record.
- From Setup, enter Apex Classes in the Quick Find box, then select Apex Classes.
- Click Schedule Apex.
- Enter the job name. We recommend Consent Record Creation, so you know what kind of record the job creates.
- Enter AsyncConsentRecordCreator in the search bar and select it.
- Specify the start and end dates for the Apex scheduled class. If you specify a single day, the job runs only once.
- Specify a preferred start time. The exact start time depends on service availability.
- Save your changes.
After the job is completed, you can see its information on the Apex Jobs page, such as whether it passed or failed, how long it took to process, and the number of records processed.

