How to resolve "Invalid index: Cannot index property 'employee' of type Text into null value of type list" this error?

local!supervisorList: if(
    contains({ 3, 6 }, ri!selectedDashboard),
    index(
      /*a!isNotNullOrEmpty(tointeger(ri!reportingEmployeeList)),*/
      ri!reportingEmployeeList,
      wherecontains(
        cons!INO_DESIG_ID_SUPERVISOR,
        tointeger(
          index(
            ri!reportingEmployeeList,
            "designationId",
            0
          )
        )
      ),
      {}
    ),
    null
  ),
  local!supervisorHierarchyList: if(
    contains({ 3, 6 }, ri!selectedDashboard),
    a!forEach(
      items: local!supervisorList,
      expression: 'type!{urn:com:appian:types:INO}INO_employeeHierarchyHelper'(
        employee: fv!item,
        directReportEmployeeList: index(
          typeof(ri!reportingEmployeeList),
          wherecontains(
            index(local!supervisorList, "internalEmpId"),
            tointeger(
              index(
                ri!reportingEmployeeList,
                "currentReportingManagerId",
                0
              )
            )
          ),
          {}
        )
        /*index(
          local!supervisorList,
          wherecontains(
            /*fv!item.internalEmpId,*/
            /*index(ri!reportingEmployeeList, "internalEmpId"),
            tointeger(
              index(
                ri!reportingEmployeeList,
                "currentReportingManagerId",
                0
              )
            )
          ),
          {}
        )*/
      )
    ),
    null
  ),

Above is my code and below is the data CDT screenshot

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    You get this error when you try to use the dot-notation to access a field in a data structure. But I do not see that in your code snippet.

    BTW, what is line 27 meant to do?

    BBTW, nested CDTs are not recommended.

  • If I without use typeof then also same error occurred. So how to resolve it. Please suggest.

    local!supervisorList: if(
        contains({ 3, 6 }, ri!selectedDashboard),
        index(
          /*a!isNotNullOrEmpty(tointeger(ri!reportingEmployeeList)),*/
          ri!reportingEmployeeList,
          wherecontains(
            cons!INO_DESIG_ID_SUPERVISOR,
            tointeger(
              index(
                ri!reportingEmployeeList,
                "designationId",
                0
              )
            )
          ),
          {}
        ),
        null
      ),
      local!supervisorHierarchyList: if(
        contains({ 3, 6 }, ri!selectedDashboard),
        a!forEach(
          items: local!supervisorList,
          expression: 'type!{urn:com:appian:types:INO}INO_employeeHierarchyHelper'(
            employee: fv!item,
            directReportEmployeeList: index(
              ri!reportingEmployeeList,
              wherecontains(
                index(local!supervisorList, "internalEmpId"),
                tointeger(
                  index(
                    ri!reportingEmployeeList,
                    "currentReportingManagerId",
                    0
                  )
                )
              ),
              {}
            )
            /*index(
              local!supervisorList,
              wherecontains(
                /*fv!item.internalEmpId,*/
                /*index(ri!reportingEmployeeList, "internalEmpId"),
                tointeger(
                  index(
                    ri!reportingEmployeeList,
                    "currentReportingManagerId",
                    0
                  )
                )
              ),
              {}
            )*/
          )
        ),
        null
      ),

  • 0
    Certified Lead Developer

    You might want to trace the datatypes of your variables.

    The error references a field of INO_employeeHierarchyHelper, but nowhere in this code are you attempting to read from that field.

    Are you sure that this is where the error is occurring?

  • 0
    Certified Lead Developer
    in reply to moulikadas

    Hm ....

    What I mean is that

    typeof(ri!reportingEmployeeList),

    returns the ID of the data type of that rule input. Trying to index() into this makes no sense for me. Help me understand what you are trying to do.

  • Yes for this part, the error is occurring. Please suggest to resolve that part

  • 0
    Certified Lead Developer
    in reply to moulikadas

    Alright, if you say so.  

    As I said, nowhere in the code listing you provided are you "Indexing property 'employee'".  Therefore, the problem is not here, or there is something you aren't telling me.  

    The listing shows the assignment of local! variables without the a!localVariables function, which means you have not provided the full expression.  

    I can't help you without more information and context:

    1. What is the datatype of the ri!s you are passing in.
    2. Code listing of the part where local!supervisorHierarchyList, is used,  (What you show is just the creation and assignment.)
    3. Does the error message list a line number?  

    Without more information, I won't be able to help you.

    As Stefan, very validly pointed out, there are other issues with your code besides the error you received.  Perhaps you might want to start with his feedback.  It's possible if you verify the logical foundations of the operations your are trying to perform, the issue may resolve itself.