Skip to main content
New Participant
Sep 22, 2022 12:55 PM UTC
Question

Expression evaluation error at function a!forEach [line 15]: Error in a!forEach() expression during iteration 77: Expression evaluation error at function 'index' parameter 1 [line 21]: Invalid index: Cannot index property 'tiePointStatus]

a!localVariables(
  local!oldCdt: rule!ITS_GetPQRRequestByPqrRequestId(pqrRequestId: 71),
  local!newCdt: rule!ITS_GetPQRRequestByPqrRequestId(pqrRequestId: 80),
  local!fields: split(
    stripwith(
      tostring(
        'type!{urn:com:appian:types:ITS}ITS_PQR_REQUEST_DETAILS'()
      ),
      "[= "
    ),
    ","
  ),
  tostring(
    a!flatten(
      a!forEach(
        items: local!fields,
        expression: {
          if(
            exact(
              if(
                isnull(local!oldCdt[fv!item]),
                "",
                local!oldCdt[fv!item]
              ),
              if(
                isnull(local!newCdt[fv!item]),
                "",
                local!newCdt[fv!item]
              )
            ),
            {},
            fv!item & ": " & local!newCdt[fv!item]
          )
        }
      )
    )
  )
),

5 replies

harshitb6843
Brainy
Sep 22, 2022 12:59 PM UTC

tiePointStatus is not accessible. Instead of dot operator, please use property() function. 

New Participant
Sep 22, 2022 1:11 PM UTC

tiePointStatus is field name of our CDT ,we are trying to compare two records which are in same CDT.

I am getting below error

Expression evaluation error at function a!forEach [line 15]: Error in a!forEach() expression during iteration 77: Expression evaluation error at function 'isnull' parameter 1 [line 21]: Invalid index: Cannot index property 'tiePointStatus]' of type Text into type ITS_PQR_REQUEST_DETAILS

harshitb6843
Brainy
Sep 22, 2022 1:24 PM UTC

a!localVariables(
  local!oldCdt: rule!ITS_GetPQRRequestByPqrRequestId(pqrRequestId: 71),
  local!newCdt: rule!ITS_GetPQRRequestByPqrRequestId(pqrRequestId: 80),
  local!fields: split(
    stripwith(
      tostring(
        'type!{urn:com:appian:types:ITS}ITS_PQR_REQUEST_DETAILS'()
      ),
      "[= "
    ),
    ","
  ),
  tostring(
    a!flatten(
      a!forEach(
        items: local!fields,
        expression: {
          if(
            exact(
              if(
                isnull(property(local!oldCdt,fv!item,{})),
                "",
                property(local!oldCdt,fv!item,{})
              ),
              if(
                isnull(property(local!newCdt,fv!item,{})),
                "",
                property(local!newCdt,fv!item,{})
              )
            ),
            {},
            fv!item & ": " & property(local!newCdt,fv!item,{})
          )
        }
      )
    )
  )
),