我在以下参数中编码:
以下是我认为可行的方法,但我收到错误:
Error: Compile Error: Method does not exist or incorrect signature: void add(String) from the type List<Opportunity> at line 27 column 17
trigger putCConRD on Opportunity (after update){
List<Opportunity> oppRecords = new List<Opportunity>();
//List<npe03__Recurring_Donation__c> rdRecords = new List<npe03__Recurring_Donation__c>();
Set<ID> associatedRDids = new Set<ID>();
List<Opportunity> oppToUpdate = new List<Opportunity>();
//For every new version of an opportunity record, add their related recurring donation to the associated Rds list.
for(Opportunity Opp : Trigger.new){
associatedRDids.add(Opp.npe03__Recurring_Donation__c);
}
oppRecords = [Select Id, ChargentSFA__Card_Month__c, ChargentSFA__Card_Year__c, ChargentSFA__Card_Number__c, ChargentSFA__Card_Security__c from Opportunity where Id in :associatedRDids];
//now we should have a list of opportunity records that are associated with the recurring donations.
//now to find the most recent close won opportunity related to that recurring donation
List<Opportunity> mostRecent = new List<Opportunity>([Select Id, ChargentSFA__Card_Month__c, ChargentSFA__Card_Year__c, ChargentSFA__Card_Number__c, ChargentSFA__Card_Security__c from Opportunity order by createdDate desc limit 1]);
for(Opportunity Opp2: oppRecords){
Opp2.ChargentSFA__Card_Month__c = mostRecent[0].ChargentSFA__Card_Month__c;
Opp2.ChargentSFA__Card_Year__c = mostRecent[0].ChargentSFA__Card_Year__c;
Opp2.ChargentSFA__Card_Number__c = mostRecent[0].ChargentSFA__Card_Number__c;
Opp2.ChargentSFA__Card_Security__c = mostRecent[0].ChargentSFA__Card_Security__c;
oppToUpdate.add(Opp2.ChargentSFA__Card_Month__c);
oppToUpdate.add(Opp2.Opp2.ChargentSFA__Card_Year__c);
oppToUpdate.add(Opp2.Opp2.ChargentSFA__Card_Number__c);
oppToUpdate.add(Opp2.Opp2.ChargentSFA__Card_Security__c);
}
update OpptoUpdate;
}
有人可以帮我弄清楚我哪里出错了吗?即使不是代码,也要感谢一些设计指导。试图将我的顶点理解扩展到基本触发之外。