Salesforce10 [Developer Beginner] Apex Testing | Test Apex Triggers trigger RestrictContactByName on Contact (before insert, before update) { //check contacts prior to insert or update for invalid data For (Contact c : Trigger.New) { if(c.LastName == 'INVALIDNAME') {//invalidname is invalid c.AddError('The Last Name "'+c.LastName+'" is not allowed for DML'); } } } // 위 트리거가 동작하는지 확인하는 테스트 코드 @isTest public class TestRestrictContactByName { // insert, update 시 la.. 2021. 3. 22. [Developer Beginner] Apex Testing | Get Started with Apex Unit Tests github.com/developerforce/trailhead-code-samples/blob/master/VerifyDate.cls 출처 developerforce/trailhead-code-samples Public code samples to support Trailhead challenges - developerforce/trailhead-code-samples github.com public class VerifyDate { //method to handle potential checks against two dates public static Date CheckDates(Date date1, Date date2) { //if date2 is within the next 30 days of d.. 2021. 3. 22. [Developer Beginner] Apex Triggers | Bulk Apex Triggers 이거 만들려면 task에 WhatId라는 custom field를 추가해줘야 하는데, task 오브젝트에선 못한다. 대신 Activity 오브젝트에 필드를 추가해주면 된다. trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) { List tasks = new List(); for(Opportunity o : Trigger.New) { if(o.StageName == 'Closed Won') { tasks.add(new Task(Subject='Follow Up Test Task', WhatId=o.Id)); } } insert tasks; } 2021. 3. 22. [Developer Beginner] Apex Triggers | Get Started with Apex Triggers 오 통과ㅋ trigger AccountAddressTrigger on Account (before insert, before update) { //BillingPostalCode //ShippingPostalCode //Match_Billing_Address__c is true, // 위는 정확한 API명 //billing postal code true && match_billing accress__c true일 때 //shipping postal code를 세팅할 것 for(Account a : Trigger.New) { if(a.Match_Billing_Address__c == true && a.BillingPostalCode != '') { a.ShippingPostalCode = a.Billing.. 2021. 3. 22. 이전 1 2 3 다음