0

I am using a batch class where data iterated over an object


Now i am trying to retrieve some fields iterating over object1

Issue - its giving me common id for provider Base value

  • Please use the tools in the editor to format your post. You can use the {} button or wrap in triple backticks (```) to format code blocks. – David Reed Aug 11 at 19:54
  • Right now, it's not clear what your issue is. Please edit your question to be more descriptive. – Derek F Aug 11 at 19:55
  • Removing the code from your question does not make it more descriptive. See How to Ask for how to phrase questions. – Dave Humm Oct 1 at 12:05
1

It appears that your formatting of code may have confused you. As written, you have a for loop within a for loop, so the values are getting written over and over again.

At minimum, this should help:

for(Object1__c obj : scope) {
    lt.add(obj.Id);
    system.debug('obj Id' +obj.Id);
}
for(object2 mmisPanel : [Some Soql query FROM Object1__c WHERE LTMS_Tracking_Number__c IN : track1 ] ){
    Map1.put(mmp.RecordType.Name, mmte);
    Map2.put(mmp.lt__r.PID_SL__r.PI_c,Map1);
}
| improve this answer | |
  • Hi, i am not using nested loop it was a null check condition which i forgot to edit while pasting the code here. Issue : ltmsTrackingList is having more than one data. Soql query also having more than one data. When i iterate over the loop to get the value .. it showing common value and not other values which should be stored in the Map – VISHAL BADONI Aug 12 at 5:27
  • am i missing something here while storing values for Map1/Map2?? – VISHAL BADONI Aug 12 at 5:36
  • @VISHALBADONI When you put a new value in a map, the old value gets removed. Since you're using RecordType.Name, you probably want to make the value of the map a list so you can get all the values. – sfdcfox Aug 12 at 15:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.