Here’s the code we’re using in the Get Started with Apex in 30 Minutes webinar!
We’re creating a trigger that simply creates a new Case when an Account is created!
Trigger
trigger TShirts on Account (after insert) { for (Account acc : Trigger.new) {Case shirtCase = new Case(); shirtCase.Subject = 'Send them a free T-shirt!'; shirtCase.Priority = 'Ultra High'; shirtCase.AccountId = acc.Id;insert shirtCase;} }
Test Class
@isTest public class TestTShirts { static testMethod void accountCreator() {Account acc = new Account(); acc.Name = 'Tesla Motors';insert acc;} }
Additional resources:
Don’t forget to sign up for the next two webinars in the series!
Thanks David and LeeAnne for your insights this morning – it was an encouraging and informational webinar!
Thank you Vijay!