Skip to main content
nicholaso0002
June 30, 2022
Solved

Amount Column repeating the same amount for each case

  • June 30, 2022
  • 3 replies
  • 0 views

I am using an XML to render a report. Each row should display a single amount per case; for example:

row 1 .--->  validation number   caseid   payee name  check amount     check no

row 2 .--->        13331                   1234       john_name             120                   blank

row 3 .--->        13332                   1234       john_name             240                   blank

row 4 .--->        13333                   1234       john_name             340                   blank

row 5 .--->        13334                   2222       Mark_name             10                   blank

row 6 .--->        13335                   2222       Mark_name             20                   blank

row 7 .--->        13336                   2222       Mark_name             30                   blank

But it is display wrongly like this:

The Expression code looks like:

a!localVariables(
  local!data: reject(
    fn!isnull,
    a!forEach(
      ri!reportData,
      if(
        rule!CheckIsNullOrEmpty(fv!item.paymentRefValidationNo),
        if(
          index(fv!item,"checkPrtSeq",{})=1,
          fv!item,
          null
        ),
        {}
      )
    )
  ),
  local!xml: {
    "" & "" & cons!RPT_NAME_003_op_CHECK_REGISTER & "" & "" & todate(local(now(), "America/Chicago")) & "" & "" & totime(local(now(), "America/Chicago")) & if(
      isindaylightsavingtime(todate(now()), "America/Chicago"),
      " CDT",
      " CST"
    ) & "" & "" & "Total: " & dollar(
      if(
        rule!APN_isBlank(local!data),
        0,
        sum(index(local!data, "paymentAmt", {}))
      )
    ) & "" & "" & tostring(todate(ri!reportDate)) & "" & "" & "Batch No" & "" & "" & "Validation Number" & "" & "" & cons!DRO_CSO_FIELD_HEADER_CASE_ID & "" & "" & "Payee Name" & "" & "" & "Check Amount" & "" & "" & cons!DRO_CSO_FIELD_HEADER_CHECK_PRT_NO & "" & "" & " " & "" & "" & " " & "" & "" & " " & "" & "" & " " & "" & "" & " " & "" & "" & " " & "" & "" & " " & "" & "" & " " & "" & "" & " " & "" & "" & " " & "" & a!forEach(
      items: local!data,
      expression: {
        ""
      }
    ) & ""
  },
  local!output: stripwith(tostring(local!xml), ";"),
  local!output
)

Any help will be greatly appreciated.

Thank you.

    Best answer by stefanhelzle0001

    I think your line 34 should reference fv!item instead of local!data.

    dollar(index(fv!item, "paymentAmt", {}))

    3 replies

    stefanhelzle0001
    Brainy
    June 30, 2022

    I think your line 34 should reference fv!item instead of local!data.

    dollar(index(fv!item, "paymentAmt", {}))

    nicholaso0002
    June 30, 2022

    I updated it to fv!item; but it seems to be returning the same output from the test rule. I will generate the report and see if it makes any difference.

    thanks

    csteward
    June 30, 2022

    Same with the local!data references on line 32 and 35, essentially all references within the a!foreach() should reference fv!item, otherwise they are pointing to the entire data set, vs the row being evaluated.