You need to sign in to do that
Don't have an account?
Arun Deepan LJ
IDs not available in Before insert. How to uniquely identify the records
Hi,
In the before insert context, the IDs are not yet assigned to the list. In such scenario, If I need to create a map to uniquely access each record. What is the best way. Cannot depend on the field values.
In the before insert context, the IDs are not yet assigned to the list. In such scenario, If I need to create a map to uniquely access each record. What is the best way. Cannot depend on the field values.
Integer size = trigger.new.size();
Map<Integer,yourObject__c> myMap = new Map<Integer,yourObject__c>();
for(yourObject__c c : trigger.new){
for(Integer i=0;i<size; i++){
myMap.put(i,c);
}
}
System.debug(myMap);
}
All Answers
Integer size = trigger.new.size();
Map<Integer,yourObject__c> myMap = new Map<Integer,yourObject__c>();
for(yourObject__c c : trigger.new){
for(Integer i=0;i<size; i++){
myMap.put(i,c);
}
}
System.debug(myMap);
}