Expression evaluation error in rule at function 'localvariables' [line 13]: LocalVariables expects final parameter to be its result value, not a definition of local variable 'local!data'? How to fix that?

if(
  not(ri!executeWhen),
  {
    data: a!dataSubset(
      startIndex: ri!pagingInfo.startIndex,
      batchSize: ri!pagingInfo.batchSize,
      sort: ri!pagingInfo.sort,
      totalCount: 0,
      data: {},
      identifiers: {}
    )
  },
  a!localVariables(
    local!employeeList: cast(
      typeof(
        {
          'type!{urn:com:appian:types:INO}INO_employee'()
        }
      ),
      ri!employeeDataSubset.data
    ),
    local!staffList: index(
      local!employeeList,
      where(
        a!forEach(
          items: local!employeeList,
          expression: and(
            tointeger(fv!item.designationId) = cons!INO_DESIG_ID_STAFF,

          )
        )
      ),
      {}
    ),
    local!employeeIdList: index(local!staffList, "internalEmpId", {}),
    local!operationsCodeIdList: index(local!staffList, "operationsCodeId", {}),
    local!dateList: if(
      isnull(ri!selectedDateList),
      {},
      todatasubset(
        a!forEach(
          items: ri!selectedDateList,
          expression: a!map(date: fv!item)
        ),
        a!pagingInfo(
          startIndex: 1,
          batchSize: - 1,
          sort: a!sortInfo(field: "date", ascending: true)
        )
      ).data.date
    ),
    local!scorecardUserLoginDailyDetailData: 
    a!localVariables(
      local!data: local!employeeIdList,
      local!batchSize: cons!INO_queryOptimisationBatchSize,
      local!numberOfIteration: int(length(local!data) / local!batchSize),
      local!md: mod(length(local!data), local!batchSize),
      local!dataToSplit: rdrop(local!data, local!md),
      if(
        length(local!employeeIdList) <= local!batchSize,
        rule!INO_queryScorecardUserLoginDailyDetail(
          pagingInfo: a!pagingInfo(
            startIndex: 1,
            batchSize: - 1,
            sort: {
              a!sortInfo(field: "internalEmpId", ascending: true),
              a!sortInfo(field: "userloginDate", ascending: true)
            }
          ),
          employeeIdList: local!employeeIdList,
          dateList: ri!selectedDateList,
          operationsCodeIdList: local!operationsCodeIdList,
          departmentId: null
        ),
        append(
          a!forEach(
            items: enumerate(local!numberOfIteration),
            expression: a!localVariables(
              local!rdp: rdrop(
                local!dataToSplit,
                (
                  local!batchSize * (local!numberOfIteration - fv!index)
                )
              ),
              local!lrdp: ldrop(local!rdp, local!batchSize * (fv!index - 1)),
              rule!INO_queryScorecardUserLoginDailyDetail
              (
                executeWhen: ri!executeWhen,
                pagingInfo: a!pagingInfo(
                  startIndex: 1,
                  batchSize: - 1,
                  sort: {
                    a!sortInfo(field: "internalEmpId", ascending: true),
                    a!sortInfo(field: "userloginDate", ascending: true)
                  }
                ),
                employeeIdList: local!lrdp,
                dateList: ri!selectedDateList,
                operationsCodeIdList: local!operationsCodeIdList,
                departmentId: null,

              )
            )
          ),
          rule!INO_queryScorecardUserLoginDailyDetail(
            executeWhen: ri!executeWhen,
            pagingInfo: a!pagingInfo(
              startIndex: 1,
              batchSize: - 1,
              sort: {
                a!sortInfo(field: "internalEmpId", ascending: true),
                a!sortInfo(field: "userloginDate", ascending: true)
                
              }
            ),
            employeeIdList: difference(local!data, local!dataToSplit),
            dateList: ri!selectedDateList,
            operationsCodeIdList: local!operationsCodeIdList,
            departmentId: null
          )
        )
      ),
    ),
    local!queryData: cast(
      typeof(
        {
          'type!{urn:com:appian:types:INO}INO_scorecard_UserloggingInfoDaily'()
        }
      ),
      index(
        local!scorecardUserLoginDailyDetailData,
        "data",
        {}
      )
    ),
    local!data: a!forEach(
      items: local!staffList,
      expression: a!localVariables(
        local!empData: index(
          local!queryData,
          wherecontains(
            fv!item.internalEmpId,
            tointeger(local!queryData.internalEmpId)
          )
        ),
        local!employee: fv!item,
        {
          a!forEach(
            items: local!dateList,
            expression: a!localVariables(
              local!userloginDate: day(fv!item),
              
              if(
                not(
                  rule!INO_isBlank(
                    index(
                      local!empData,
                      where(
                        a!forEach(
                          items: local!empData,
                          expression: and(
                            fv!item.userloginDate = local!userloginDate,
                            
                          )
                        )
                      ),
                      null
                    )
                  )
                ),
                index(
                  local!empData,
                  where(
                    a!forEach(
                      items: local!empData,
                      expression: and(
                        fv!item.userloginDate = local!userloginDate
                        
                      )
                    )
                  ),
                  null
                ),

                'type!{urn:com:appian:types:INO}INO_scorecard_UserloggingInfoDaily'(

                  internalEmpId: index(local!employee, "internalEmpId", null),
                  /*hireDate: index(local!employee, "hireDate", null),*/
                  userloginDate: day(fv!item),
                  dimSupervisorID: tointeger(
                    index(
                      local!empData.dimSupervisorID,
                      where(
                        a!forEach(
                          items: local!empData,
                          expression: and(
                            index(local!empData, "userloginDate") = local!userloginDate
                            
                          )
                        )
                      ),
                      null
                    )
                  ),
                  dimManagerID: tointeger(
                    index(
                      local!empData.dimManagerID,
                      where(
                        a!forEach(
                          items: local!empData,
                          expression: and(
                            index(local!empData, "userloginDate") = local!userloginDate
                          )
                        )
                      ),
                      null
                    )
                  )
                )
              )
            )
          )  /*Doubt about CDT*/
        }
      )
    ),
   /* local!filterDataByHireDate: a!forEach(
      items: local!data,
      expression: a!localVariables(
        local!upperIndex: fv!index,
        a!forEach(
          items: fv!item,
          expression: a!localVariables(
            local!hiredate: date(
              year(
                if(
                  rule!INO_isBlank(fv!item.hireDate),
                  today(),
                  fv!item.hireDate
                )
              ),
              month(
                if(
                  rule!INO_isBlank(fv!item.hireDate),
                  today(),
                  fv!item.hireDate
                )
              ),
              1
            ),
            local!selectedDate: day(fv!item.userloginDate),
            if(
              local!selectedDate < local!hiredate,
              'type!{urn:com:appian:types:INO}INO_scorecard_UserloggingInfoDaily'(
                internalEmpId: fv!item.internalEmpId,
                hireDate: fv!item.hireDate,
                userloginDate: fv!item.userloginDate,
                dimSupervisorID: fv!item.dimSupervisorID,
                dimManagerID: fv!item.dimManagerID
              ),
              fv!item
            )
          )
        ),

      )
    ),*/ 
    /*Doubt about CDT*/
   /*{
      data: todatasubset(
        cast(
          typeof(
            {
              'type!{urn:com:appian:types:INO}INO_scorecard_UserloggingInfoDaily'()
            }
          ),
          append(
            local!filterDataByHireDate,
          )
        ),
        a!pagingInfo(
          startIndex: 1,
          batchSize: - 1,
          sort: ri!pagingInfo.sort
        )
      ),
    }*/
  )
)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer
    in reply to moulikadas

    if(
      not(ri!executeWhen),
      {
        data: a!dataSubset(
          startIndex: ri!pagingInfo.startIndex,
          batchSize: ri!pagingInfo.batchSize,
          sort: ri!pagingInfo.sort,
          totalCount: 0,
          data: {},
          identifiers: {}
        )
      },
      a!localVariables(
        local!employeeList: cast(
          typeof(
            {
              'type!{urn:com:appian:types:INO}INO_employee'()
            }
          ),
          ri!employeeDataSubset.data
        ),
        local!staffList: index(
          local!employeeList,
          where(
            a!forEach(
              items: local!employeeList,
              expression: and(
                tointeger(fv!item.designationId) = cons!INO_DESIG_ID_STAFF,
    
              )
            )
          ),
          {}
        ),
        local!employeeIdList: index(local!staffList, "internalEmpId", {}),
        local!operationsCodeIdList: index(local!staffList, "operationsCodeId", {}),
        local!dateList: if(
          isnull(ri!selectedDateList),
          {},
          todatasubset(
            a!forEach(
              items: ri!selectedDateList,
              expression: a!map(date: fv!item)
            ),
            a!pagingInfo(
              startIndex: 1,
              batchSize: - 1,
              sort: a!sortInfo(field: "date", ascending: true)
            )
          ).data.date
        ),
        local!scorecardUserLoginDailyDetailData: 
        a!localVariables(
          local!data: local!employeeIdList,
          local!batchSize: cons!INO_queryOptimisationBatchSize,
          local!numberOfIteration: int(length(local!data) / local!batchSize),
          local!md: mod(length(local!data), local!batchSize),
          local!dataToSplit: rdrop(local!data, local!md),
          if(
            length(local!employeeIdList) <= local!batchSize,
            rule!INO_queryScorecardUserLoginDailyDetail(
              pagingInfo: a!pagingInfo(
                startIndex: 1,
                batchSize: - 1,
                sort: {
                  a!sortInfo(field: "internalEmpId", ascending: true),
                  a!sortInfo(field: "userloginDate", ascending: true)
                }
              ),
              employeeIdList: local!employeeIdList,
              dateList: ri!selectedDateList,
              operationsCodeIdList: local!operationsCodeIdList,
              departmentId: null
            ),
            append(
              a!forEach(
                items: enumerate(local!numberOfIteration),
                expression: a!localVariables(
                  local!rdp: rdrop(
                    local!dataToSplit,
                    (
                      local!batchSize * (local!numberOfIteration - fv!index)
                    )
                  ),
                  local!lrdp: ldrop(local!rdp, local!batchSize * (fv!index - 1)),
                  rule!INO_queryScorecardUserLoginDailyDetail
                  (
                    executeWhen: ri!executeWhen,
                    pagingInfo: a!pagingInfo(
                      startIndex: 1,
                      batchSize: - 1,
                      sort: {
                        a!sortInfo(field: "internalEmpId", ascending: true),
                        a!sortInfo(field: "userloginDate", ascending: true)
                      }
                    ),
                    employeeIdList: local!lrdp,
                    dateList: ri!selectedDateList,
                    operationsCodeIdList: local!operationsCodeIdList,
                    departmentId: null,
    
                  )
                )
              ),
              rule!INO_queryScorecardUserLoginDailyDetail(
                executeWhen: ri!executeWhen,
                pagingInfo: a!pagingInfo(
                  startIndex: 1,
                  batchSize: - 1,
                  sort: {
                    a!sortInfo(field: "internalEmpId", ascending: true),
                    a!sortInfo(field: "userloginDate", ascending: true)
    
                  }
                ),
                employeeIdList: difference(local!data, local!dataToSplit),
                dateList: ri!selectedDateList,
                operationsCodeIdList: local!operationsCodeIdList,
                departmentId: null
              )
            )
          ),
        ),
        local!queryData: cast(
          typeof(
            {
              'type!{urn:com:appian:types:INO}INO_scorecard_UserloggingInfoDaily'()
            }
          ),
          index(
            local!scorecardUserLoginDailyDetailData,
            "data",
            {}
          )
        ),
        local!data: a!forEach(
          items: local!staffList,
          expression: a!localVariables(
            local!empData: index(
              local!queryData,
              wherecontains(
                fv!item.internalEmpId,
                tointeger(local!queryData.internalEmpId)
              )
            ),
            local!employee: fv!item,
            {
              a!forEach(
                items: local!dateList,
                expression: a!localVariables(
                  local!userloginDate: day(fv!item),
    
                  if(
                    not(
                      rule!INO_isBlank(
                        index(
                          local!empData,
                          where(
                            a!forEach(
                              items: local!empData,
                              expression: and(
                                fv!item.userloginDate = local!userloginDate,
    
                              )
                            )
                          ),
                          null
                        )
                      )
                    ),
                    index(
                      local!empData,
                      where(
                        a!forEach(
                          items: local!empData,
                          expression: and(
                            fv!item.userloginDate = local!userloginDate
    
                          )
                        )
                      ),
                      null
                    ),
    
                    'type!{urn:com:appian:types:INO}INO_scorecard_UserloggingInfoDaily'(
    
                      internalEmpId: index(local!employee, "internalEmpId", null),
                      hireDate: index(local!employee, "hireDate", null),
                      userloginDate: day(fv!item),
                      dimSupervisorID: tointeger(
                        index(
                          local!empData.dimSupervisorID,
                          where(
                            a!forEach(
                              items: local!empData,
                              expression: and(
                                index(local!empData, "userloginDate") = local!userloginDate
    
                              )
                            )
                          ),
                          null
                        )
                      ),
                      dimManagerID: tointeger(
                        index(
                          local!empData.dimManagerID,
                          where(
                            a!forEach(
                              items: local!empData,
                              expression: and(
                                index(local!empData, "userloginDate") = local!userloginDate
                              )
                            )
                          ),
                          null
                        )
                      )
                    )
                  )
                )
              )  /*Doubt about CDT*/
            }
          )
        ),
        local!data
      )
    )


    Try this for once.

  • If I put this one then no data showing.. just the true part has executed and if I put the data then the data is showing null like. [data:[startIndex=1, batchSize=1, sort=, totalCount=0, data=, identifiers=]]. Please suggest

Reply Children