public without sharing class FixtureSetDetailHandler extends Oly_TriggerHandler { private Map newMap; private Map oldMap; private List newList; private List oldList; public FixtureSetDetailHandler() { this.newMap = (Map) Trigger.newMap; this.oldMap = (Map) Trigger.oldMap; this.newList = (List) Trigger.new; this.oldList = (List) Trigger.old; } protected override void beforeInsert() { beforeSetValue(); } protected override void beforeUpdate() { beforeSetValue(); } private void beforeSetValue() { Map fsdMap = new Map(); for (Fixture_Set_Detail__c nObj : newList) { nObj.Name_CHN_Created__c = nObj.Name_CHN__c; // 20230727 ljh ±¸Æ·ÀàÐÍIºÍ±¸Æ·ÀàÐÍII·Åµ½±£ÓÐÉ豸ÉÏÏÔʾ start if(nObj.Loaner_category__c){ fsdMap.put(nObj.Fixture_Model_No_F__c,nObj); } } // 20230727 ljh ±¸Æ·ÀàÐÍIºÍ±¸Æ·ÀàÐÍII·Åµ½±£ÓÐÉ豸ÉÏÏÔʾ start if(fsdMap.size() > 0){ List Product2List = [SELECT Id,Fixture_Model_No_T__c,Loaner_categoryI__c,Loaner_categoryII__c FROM Product2 WHERE Fixture_Model_No_T__c IN :fsdMap.keySet()]; if(Product2List.size() > 0){ Map updateMap = new Map(); for(Product2 pro:Product2List){ Product2 p2 = new Product2(); p2.Id = pro.Id; p2.Loaner_categoryI__c = fsdMap.get(pro.Fixture_Model_No_T__c).Loaner_categoryI__c; p2.Loaner_categoryII__c =fsdMap.get(pro.Fixture_Model_No_T__c).Loaner_categoryII__c; if(((String.isNotBlank(p2.Loaner_categoryI__c) && p2.Loaner_categoryI__c.equals(pro.Loaner_categoryI__c)) || (String.isBlank(p2.Loaner_categoryI__c)&&String.isBlank(pro.Loaner_categoryI__c))) && ((String.isNotBlank(p2.Loaner_categoryII__c) && p2.Loaner_categoryII__c.equals(pro.Loaner_categoryII__c)) || (String.isBlank(p2.Loaner_categoryII__c)&&String.isBlank(pro.Loaner_categoryII__c)))){ continue; } updateMap.put(pro.Id,p2); } if(updateMap.size() > 0){ update updateMap.values(); } } } // 20230727 ljh ±¸Æ·ÀàÐÍIºÍ±¸Æ·ÀàÐÍII·Åµ½±£ÓÐÉ豸ÉÏÏÔʾ start } }