Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trigger PullProjectNoOpportunity on SAP_Sales_Order__c (before update) {
- Set<String> codes = new Set<String>();
- for (SAP_Sales_Order__c o : trigger.new) codes.add(o.SAP_Project_NO__c);
- Map<String, Opportunity> pronumOpportunities = new Map<String, Opportunity>();
- for (Opportunity a : [
- SELECT Cilioproject__c FROM Opportunity
- WHERE Cilioproject__c IN :codes
- ]) pronumOpportunities.put(a.Cilioproject__c, a);
- for (SAP_Sales_Order__c o : Trigger.new)
- {
- Opportunity pronumOpportunity = pronumOpportunities.get(o.SAP_Project_NO__c);
- Id parentId = (pronumOpportunity == null) ? null : pronumOpportunity.Id;
- o.project__c = parentId;
- }
- }
- @isTest
- private class testPullProjectNoOpportunity {
- static testMethod void validateLookupPopulation() {
- SAP_Sales_Order__c SO = new SAP_Sales_Order__c(name='9999999');
- SO.SAP_Project_No__c = '30157';
- insert SO;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement