Entradas

Mostrando las entradas de septiembre, 2019

Solving Subscribe to a Platform Event in an Apex Trigger Challange

The trailhead challange says: Your Salesforce app uses a trigger to listen to events. Once your app receives the notification from the order system through the trigger, it creates a task to follow up on the order shipment. Create an Apex trigger named  OrderEventTrigger  for Order_Event__e. This trigger will be similar to the CloudNewsTrigger trigger, but operates on the Order_Event__e event and creates tasks instead of cases. If the order has shipped ( event.Has_Shipped__c == true ), create a task with the following values: Priority:  'Medium' Subject:  'Follow up on shipped order ' + event.Order_Number__c OwnerId:  event.CreatedById (Note: You are assigning the task OwnerId to the same user who published the event. This step keep things simple so you don't have to perform any prerequisites.) For this, you only need to create the  OrderEventTrigger: trigger OrderEventTrigger on Order_Event__e ( after insert ) { //List to hold all tasks

Solving Schedule Jobs Using the Apex Scheduler

The Trailhead challenge says: Create an Apex class that uses Scheduled Apex to update Lead records. Create an Apex class that implements the Schedulable interface to update Lead records with a specific LeadSource. Write unit tests that achieve 100% code coverage for the class. This is very similar to what you did for Batch Apex. Create an Apex class called 'DailyLeadProcessor' that uses the Schedulable interface. The execute method must find the first 200 Leads with a blank LeadSource field and update them with the LeadSource value of 'Dreamforce'. Create an Apex test class called 'DailyLeadProcessorTest'. In the test class, insert 200 Lead records, schedule the DailyLeadProcessor class to run and test that all Lead records were updated correctly. The unit tests must cover all lines of code included in the DailyLeadProcessor class, resulting in 100% code coverage. Run your test class at least once (via 'Run All' tests the Developer Console) befo

Solving Use Batch Apex Challenge

The Trailhead challenge says: Create an Apex class that uses Batch Apex to update Lead records. Create an Apex class that implements the Database.Batchable interface to update all Lead records in the org with a specific LeadSource. Write unit tests that achieve 100% code coverage for the class. Create an Apex class called 'LeadProcessor' that uses the Database.Batchable interface. Use a QueryLocator in the start method to collect all Lead records in the org. The execute method must update all Lead records in the org with the LeadSource value of 'Dreamforce'. Create an Apex test class called 'LeadProcessorTest'. In the test class, insert 200 Lead records, execute the 'LeadProcessor' Batch class and test that all Lead records were updated correctly. The unit tests must cover all lines of code included in the LeadProcessor class, resulting in 100% code coverage. Run your test class at least once (via 'Run All' tests the Developer Console)