Error Evaluating UI Expression in a!gridField_19r1

Hi All,

I am getting below error when trying to change the filter selections. Attached is the code snippet. Could someone please help where should I add the a!save to reset the start index to 1 ?

Error:

Expression evaluation error [evaluation ID = FBD3FFMB] in rule 'safety_dashboard_taskreport' at function a!gridField_19r1 [line 1439]: A grid component [label=“”] has an invalid value for “value” and “totalCount”. “startIndex” must not be greater than “totalCount”, but “startIndex” was 11 and “totalCount” was 0.

Thanks in advance.

load(
  local!caseId,
  local!pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 10,
    sort: a!sortInfo(
      field: "c4",
      ascending: false
    )
  ),
  local!gridSelection: a!gridSelection(
    pagingInfo: local!pagingInfo,
    selected: {}
  ),
  local!assignedToIndex: 1,
  local!reassignedUser,
  local!success: false(),
  with(
    local!taskSubset: a!queryProcessAnalytics(
      report: cons!SAFETY_DOCUMENT_TASKS_REPORT,
      contextProcessModels: {
        cons!SAFETY_PROCESS_INITIATE_REVIEW
      },
      query: a!query(
        logicalExpression: a!queryLogicalExpression(
          operator: "AND",
          filters: {
            /*My Tasks Filter*/
            a!queryFilter(
              field: "c5",
              operator: "=",
              value: loggedInUser(),
              applyWhen: local!assignedToIndex = 1
            ),
            /*Case Id Filter*/
            a!queryFilter(
              field: "c4",
              operator: "=",
              value: local!caseId,
              applyWhen: not(
                rule!APN_isBlank(
                  local!caseId
                )
              )
            )
          },
          logicalExpressions: a!queryLogicalExpression(
            operator: "OR",
            filters: {
              /*My Group Filter*/
              a!queryFilter(
                field: "c7",
                operator: "=",
                value: true,
                applyWhen: and(
                  local!assignedToIndex = 2,
                  isusermemberofgroup(
                    loggedInUser(),
                    cons!SAFETY_LENDERS
                  )
                )
              ),
         a!queryFilter(
                field: "c15",
                operator: "=",
                value: true,
                applyWhen: and(
                  local!assignedToIndex = 2,
                  isusermemberofgroup(
                    loggedInUser(),
                    cons!SAFETY_APPROVERS
                  )
                )
              ),
                     
             a!queryFilter(
                field: "c32",
                operator: "=",
                value: true,
                applyWhen: and(
                  local!assignedToIndex = 2,
                  isusermemberofgroup(
                    loggedInUser(),
                    cons!SAFETY_VIEWERS
                  )
                )
              ),
              a!queryFilter(
                field: "c34",
                operator: "=",
                value: true,
                applyWhen: and(
                  local!assignedToIndex = 2,
                  isusermemberofgroup(
                    loggedInUser(),
                    cons!SAFETY_PAYERS
                  )
                )
              )
            },
            logicalExpressions: a!queryLogicalExpression(
              operator: "OR",
              filters: {
                if(
                  local!assignedToIndex = 2,
                  if(
                    contains(
                      getgroupmemberuserspaging(
                        cons!SAFETY_RAISERS,
                        0,
                        - 1
                      ),
                      loggedInUser()
                    ),
                    a!forEach(
                      items: apply(
                        cast(
                          27,
                          _
                        ),
                        getgroupmemberuserspaging(
                          togroup(
                            getgroupbyname(
                              "SAFETY RAISERS"
                            )
                          ),
                          0,
                          - 1
                        )
                      ),
                      expression: a!queryFilter(
                        field: "c5",
                        operator: "in",
                        value: fv!item
                      )
                    ),
                                           if(
                                                                      contains(
                                                                        getgroupmemberuserspaging(
                                                                          cons!SAFETY_WAIVERS,
                                                                          0,
                                                                          - 1
                                                                        ),
                                                                        loggedInUser()
                                                                      ),
                                                                      a!forEach(
                                                                        items: apply(
                                                                          cast(
                                                                            27,
                                                                            _
                                                                          ),
                                                                          getgroupmemberuserspaging(
                                                                            togroup(
                                                                              getgroupbyname(
                                                                                "SAFETY WAIVERS"
                                                                              )
                                                                            ),
                                                                            0,
                                                                            - 1
                                                                          )
                                                                        ),
                                                                        expression: a!queryFilter(
                                                                          field: "c5",
                                                                          operator: "in",
                                                                          value: fv!item
                                                                        )
                                                                      ),
                                                                      {}
                                                                    )
                                                                  )
                                 
                    
                  ),
                  {}
                )
              }
            )
          )
        ),
        pagingInfo: local!gridSelection.pagingInfo
      )
    ),
    {
      /*Task Filter*/
      a!boxLayout(
        label: "Filter Tasks",
        contents: {
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!radioButtonField(
                    choiceLayout: "COMPACT",
                    choiceLabels: {
                      "Me",
                      "My Groups",
                      "Everyone"
                    },
                    choiceValues: {
                      1,
                      2,
                      3
                    },
                    value: local!assignedToIndex,
                    saveInto: {
                      local!assignedToIndex,
                      a!save(
                        local!gridSelection.selected,
                        null
                      ),
                      a!save(
                        local!success,
                        null
                      )
                    },
                               
                  )
                }
              ),
              a!columnLayout(
                contents: {
                  a!integerField(
                    labelPosition: "COLLAPSED",
                    placeholder: "Case ID",
                    value: local!caseId,
                    saveInto: {
                      local!caseId,
                      a!save(
                        local!pagingInfo,
                        a!pagingInfo(
                          startIndex: 1,
                          batchSize: 10,
                          sort: a!sortInfo(
                            "c4",
                            false
                          )
                        )
                      )
                    }
                  )
                }
              ),
              a!columnLayout(
                contents: {
                  a!buttonArrayLayout(
                    buttons: {
                      a!buttonWidget(
                        label: "Reset Filters",
                        style: "DESTRUCTIVE",
                        size: "SMALL",
                        saveInto: {
                          a!save(
                            local!assignedToIndex,
                            1
                          ),
                          a!save(
                            {
                              local!caseId,
                              local!reassignedUser
                            },
                            null
                          ),
                          a!save(
                            local!pagingInfo,
                            a!pagingInfo(
                              startIndex: 1,
                              batchSize: 10,
                              sort: a!sortInfo(
                                "c4",
                                false
                              )
                            )
                          )
                        }
                      )
                    },
                    marginBelow: "NONE"
                  )
                }
              )
            }
          ),
          
        },
        style: "ACCENT",
        isCollapsible: true
      ),
      /*Extra Space*/
      a!richTextDisplayField(),
      a!richTextDisplayField(),
      /*Tasks Grid*/
      a!columnsLayout(
        columns: {
          a!columnLayout(),
          a!columnLayout(
            contents: {
              a!sideBySideLayout(
                items: {
                  a!sideBySideItem(
                    item: a!richTextDisplayField(
                      labelPosition: "COLLAPSED"
                    )
                  ),
                  a!sideBySideItem(
                    item: a!richTextDisplayField(
                      labelPosition: "COLLAPSED"
                    ),
                    width: "MINIMIZE"
                  ),
                  a!sideBySideItem(),
                  a!sideBySideItem(
                    item: a!buttonArrayLayout(
                      buttons: {
                        a!buttonWidget(
                          label: "Assign To Me",
                          style: "PRIMARY",
                          confirmMessage: "Do you want to Re-Assign the Selected Task(s) to you",
                          submit: true,
                          size: "SMALL",
                          disabled: rule!APN_isBlank(
                            local!gridSelection.selected
                          ),
                          showWhen: local!assignedToIndex = 2,
                          saveInto: {
                            a!startProcess(
                              processModel: cons!SAFETY_PM_TASK_REASSIGNMENT,
                              processParameters: {
                                taskIDs: local!gridSelection.selected
                              },
                              onSuccess: {
                                a!save(
                                  local!success,
                                  fv!processInfo.pv.success
                                )
                              },
                              onError: {}
                            ),
                            a!save(
                              local!gridSelection.selected,
                              null
                            ),
                            a!save(
                              target: local!gridSelection.pagingInfo.startIndex,
                              value: 1
                            )
                          }
                        )
                      },
                      marginBelow: "NONE"
                    ),
                    width: "MINIMIZE"
                  )
                },
                alignVertical: "MIDDLE"
              ),
              a!richTextDisplayField(
                value: a!richTextItem(
                  text: "Tasks has been Re-Assigned to you",
                  style: "STRONG",
                  color: "POSITIVE"
                ),
                showWhen: and(
                  toboolean(
                    local!success
                  ) = true(),
                  local!assignedToIndex = 2
                ),
                align: "RIGHT"
              )
            }
          )
        }
      ),
      a!gridField_19r1(
        totalCount: local!taskSubset.totalCount,
        columns: {
          /*Task Name*/
          a!gridTextColumn(
            label: "Task",
            field: "c0",
            data: index(
              local!taskSubset.data,
              "c0",
              null
            ),
            links: a!forEach(
              items: index(
                local!taskSubset.data,
                "c2",
                null
              ),
              expression: if(
                rule!APN_isBlank(
                  fv!item
                ),
                null,
                a!processTaskLink(
                  task: fv!item
                )
              )
            )
          ),
          /*Case ID*/
          a!gridTextColumn(
            label: "Case ID",
            alignment: "CENTER",
            field: "c4",
            data: index(
              local!taskSubset.data,
              "c4",
              null
            ),
            links: a!forEach(
              items: index(
                local!taskSubset.data,
                "c4",
                null
              ),
              expression: if(
                rule!APN_isBlank(
                  fv!item
                ),
                null,
                a!recordLink(
                  recordType: cons!SAFETY_RECORD_ALL_CASES,
                  identifier: fv!item
                )
              )
            )
          ),
          /*Task Assignee*/
          a!gridTextColumn(
            label: "Task Assignees",
            alignment: "CENTER",
            field: "c5",
            data: a!forEach(
              items: index(
                local!taskSubset.data,
                "c5",
                null
              ),
              expression: rule!SAFETY_Rule_Text_displayUserGroupName(
                fv!item,
                true
              )
            )
          ),
          /*Reporting Month*/
          a!gridTextColumn(
            label: "Reporting Month",
            alignment: "CENTER",
            field: "c3",
            data: if(
              rule!APN_isBlank(
                index(
                  local!taskSubset.data,
                  "c3",
                  {}
                )
              ),
              {},
              a!forEach(
                items: local!taskSubset.data,
                expression: rule!SAFETY_RULE_ExtractReportingMonth(
                  fv!item.c3
                )
              )
            )
          ),
          /*Start Time*/
          a!gridTextColumn(
            label: "Initiated On",
            alignment: "RIGHT",
            field: "c3",
            data: index(
              local!taskSubset.data,
              "c3",
              null
            )
          )
        },
        identifiers: local!taskSubset.identifiers,
        value: local!gridSelection,
        saveInto: {
          local!gridSelection,
          a!save(
            local!success,
            false()
          )
        },
        selection: if(
          local!assignedToIndex = 2,
          true,
          false
        ),
        emptyGridMessage: "No tasks available"
      )
    }
  )
)

  Discussion posts and replies are publicly visible