Issue while batching list of text string

Certified Associate Developer

Hi Team,

Im trying a batch list of text items and prepare a query based on that. Below is my code snippet. With this code Im getting the last item of each list for the full batch of 50 items.

local!getAgreementIds: if(
    rule!APN_isBlank(
      index(
        index(local!PartnersResult, "data", null),
        "agreement__cr.id",
        null
      )
    ),
    index(
      local!AgreementResult.data,
      "agreement__cr.id",
      null
    ),
    index(
      local!PartnersResult.data,
      "agreement__cr.id",
      null
    )
  ),
  local!agreementDocIds: touniformstring(rule!APN_distinct(local!getAgreementIds)),
  
  local!batchedDocIds: a!forEach(
    items: enumerate(ceiling(length(local!agreementDocIds) / 50)),
    expression: local!agreementDocIds[
      (fv!item * 50) + 1 :
      min((fv!item + 1) * 50, length(local!agreementDocIds))
    ]
  ),
   

For ex: I have a list of 59 items, when I try to batch I should get 50 items in 1 batch and remaining 9 items in another batch. But Im getting last item of each batch that is 50th item in first batch and 59th item in 2nd batch. Can someone please help 

  Discussion posts and replies are publicly visible