I have a method that loops through one map and adds relevant information from a another map.
Looking at the output from the debug statements - the two ids are different, specificially one includes FF and the other includes FG. However when interrogated again they're both FG.What's going on? How do I fix this? I have tried changing API version of the code - no luck.for(id opp : opps.keySet()){
id dg = opps.get(opp);
if (templates.containsKey(dg) ) {
list<npsp__Allocation__c> thisTemplate = templates.get(dg);
for (npsp__Allocation__c t : thisTemplate) {
t.npsp__Opportunity__c = opp;
toInsert.add(t);
system.debug('added: '+toInsert[toInsert.size()-1].npsp__Opportunity__c); // << ⌗1
}
}
}
system.debug('------------------ ');
for (npsp__Allocation__c a : toInsert ) system.debug(a.npsp__Opportunity__c); // << ⌗2
1 answer
in case others run into this type of issue in the future - the problem boiled down to passing values by reference vs. by value.
instead of above - it was solved by createing a new npsp__Allocation__c and copying values to it, then adding it.t.npsp__Opportunity__c = opp;
toInsert.add(t);