You need to sign in to do that
Don't have an account?
hogehoge
Please tell me how to write the test class.
Help me! Apex Trigger test code
trigger ResultCustomerTrigger on Result__c (Before insert,Before update) { Set<Id> oppIdSet = new Set<Id>(); for (Result__c m : Trigger.new){ oppIdSet.add(m.vupOpportunity__c); } List<Opportunity> OpportunityList =[SELECT Id,Vup_No__c,Account.Name FROM Opportunity WHERE Id =: oppIdSet]; Map<Id,Opportunity> OppMap = new Map<Id,Opportunity>(); for (Opportunity opp : OpportunityList){ OppMap.put(opp.Id,opp); } for (Result__c m : Trigger.new){ Opportunity opp = (Opportunity)OppMap.get(m.vupOpportunity__c); if ( opp != null) { if (m.DeliveryDestination__c == null && m.ProjectNo__c == null) { m.DeliveryDestination__c = opp.AccountId; m.ProjectNo__c = opp.Vup_No__c; } } } }
Please tell me how to write the test class.
try with below code.
Let me know if any issues.
If this helps, Please mark it as best answer.
Thanks!!