title: What is wrong with code - Trying to batch agent with similar account ID?
body: <p>I am trying to batch Sales Invoice per customer . My agents are Invoice. I am looping through each of the account and checking how many invoices are there for each customer. Based on that changing the batch size. the batch Size calculated seems correct but the batching is not happening and batchSize is printed as 1 for each account.</p>
  <pre><code>LinkedHashMap&lt;Integer, List&lt;MyAgent&gt;&gt; productsWaiting = new 
  LinkedHashMap&lt;Integer, List&lt;MyAgent&gt;&gt;();
  
  for (int i = 0; i &lt; wait.size(); i ++){
  
  MyAgent myAgent = wait.get(i);
  int id = myAgent.actNo;
  if (!productsWaiting.containsKey(id)) productsWaiting.put(id, new ArrayList&lt;MyAgent&gt;());
  productsWaiting.get(id).add(myAgent);
  
   }
  
  for (int key : productsWaiting.keySet())
  {
  int id= key;
   batchsize= productsWaiting.get(id).size();
   batch1.set_batchSize(batchsize);
  
   traceln(&quot;iD: &quot; + id  + &quot;   batchsize    &quot;  +  batchsize);
  
      for (MyAgent p:productsWaiting.get(id)) {
        
          //System.out.println(x);
          //traceln(&quot;actNo&quot; +p.actNo  );
          batch1.set_batchSize(batchsize);
          wait.free(p);
          batch1.set_batchSize(batchsize);
                        
          traceln(batch1.batchSize);
          
          //System.out.println(&quot;Released  &quot; +&quot;Batch Size  &quot; + x + &quot;account ID-&quot; + id);
   
      }
      
  } 
  
     
  </code></pre>
  <p>Unable to change the batch size for each of account based on the invoices it contains.</p>
  <p>Some logs are here</p>
  <pre><code>iD: 165691   batchsize    1
  iD: 120895   batchsize    1
  iD: 85295   batchsize    1
  iD: 5080702   batchsize    2
  iD: 121437   batchsize    1
  iD: 174098   batchsize    1 
  </code></pre>
  <p>On the entry of the batch block I checked the batach Size ..</p>
  <pre><code>165691
  
  batch Size    1
  
  120895
  
  batch Size    1
  
  85295
  
  batch Size    1
  
  5080702
  
  batch Size    1
  
  5080702
  
  batch Size    1
  
  121437
  
  batch Size    1
  
  174098
  
  batch Size    1
  </code></pre>
  <p>Every entry of agent has batch size of 1..  Could you pls point out the mistake in the code.</p>