You need to sign in to do that
Don't have an account?
davidjbb
Apex List
for(jbbfc2__MaterialU__c mu :[select jbbfc2__Workorder__c,jbbfc2__Workorder__r.Id, Name, jbbfc2__Material__r.jbbfc2__ProductCode__c,jbbfc2__Material__r.jbbfc2__UnitPrice__c,jbbfc2__quantity__c from jbbfc2__MaterialU__c where jbbfc2__Workorder__r.jbbfc2__Status__c ='Closed']) { System.debug('Workorder Id' + mu.jbbfc2__Workorder__r.Id); System.debug('Material' + mu.Name); matList.add(mu); if(muMap.get(mu.jbbfc2__Workorder__r.Id)==null){ muMap.put(mu.jbbfc2__Workorder__r.Id, matList); } }
For matList.add(mu);
It's adding all the materials to the matList regardless which jbbfc2__Workorder__r.Id it belongs too..How can i fix this? Right now i'm just adding all the records in the matList
If you are trying to have a materials list per workorder, you need to use the one in the map.
Something like:
This retrieves the list for the workorder from the map, creates a new one if it is null and stores it in the map, and then appends the material to the list.
All Answers
If you are trying to have a materials list per workorder, you need to use the one in the map.
Something like:
This retrieves the list for the workorder from the map, creates a new one if it is null and stores it in the map, and then appends the material to the list.
Exactly what I needed. Thanks!!
Learning so much today.