remove(list,index) not work

sorry, i don't know why my remove function not work in a editable grid.

a!save(list,remove(list,fv!index)) can successfully delete the first one in the grid, but if i delete twice the second one not change, the list didn't remove anything as well? any one help? hurry

a!localVariables(
  local!deleteDocument: tostring(loggedInUser()),
  local!a: document(34081, "folderName"),
  local!documentChildren: a!refreshVariable(folder(1685, "documentChildren")),
  local!documentChild,
  local!newFile,
  local!newFileInfo,
  local!documentInfo: 'type!{urn:com:appian:types:KONE}CSE_DOCUMENTS'(),
  local!fileId,
  local!deleteIndex:0,
  local!UserDocuments: a!refreshVariable(
    if(
      isnull(ri!tenderId),
      {},
      rule!CSE_USERDOCUMENTMATCH(
        tostring(loggedInUser()),
        tointeger(ri!tenderId)
      )
    )
  ),

  
  local!flattenfilelist: a!flatten(a!forEach(
    items: local!documentChildren,
    expression: a!localVariables(
      local!documentChild: fv!item,
      a!forEach(
        items: local!UserDocuments,
        expression: if(

          document(local!documentChild,"id")=tointeger(fv!item.documentid),
          fv!item,{}
        ),
      )
  ))),
  a!sectionLayout(
    contents: {
      a!richTextDisplayField(
        labelPosition: "COLLAPSED",
        value: {
          a!richTextItem(
            text: {
              a!richTextIcon(icon: "FILE", caption: "Name"),
              " Edit Documents"
            },
            color: "ACCENT",
            size: "LARGE",
            style: { "PLAIN" },
            showWhen:false(),
          )
        }
      ),
      a!fileUploadField(
        label: "New File Upload",
        labelPosition: "COLLAPSED",
        target: cons!CSE_TENDER_COMMENTS_FOLDER,
        maxSelections: 25,
        value: local!newFile,
        showWhen: if(
          isnull(ri!tenderId),
          false(),
          {
            if(
              contains(
                a!forEach(
                  items: rule!CSE_CSETENDER_IDOWNER(ri!tenderId),
                  expression: fv!item
                ),
                tostring(loggedInUser())
              ),
              true,
              false,
              
            )
          }
        ),
        saveInto: {
          a!save(target: local!newFile, value: save!value),
          a!save(
            target: local!fileId,
            value: tointeger(local!newFile),
            
          ),
          a!save(
            target: local!documentInfo.DOCUMENT_TYPE_ID,
            value: a!forEach(items: local!fileId, expression: fv!item)
          ),
          a!save(
            target: local!documentInfo.TITLE,
            value: a!forEach(items: local!fileId, expression: " ", )
          ),
          a!save(
            target: local!documentInfo.ENTITY_ID,
            value: a!forEach(
              items: local!fileId,
              expression: ri!tenderId,
              
            )
          ),
          a!save(
            target: local!documentInfo.ACTIVE,
            value: a!forEach(items: local!fileId, expression: 1)
          ),
          a!save(
            target: local!documentInfo.CREATED_BY,
            value: a!forEach(
              items: local!fileId,
              expression: loggedInUser(),
            )
          ),
          
        },
        validations: {}
      ),
      a!buttonArrayLayout(
        buttons: {
          a!buttonWidget(
            label: "save into Folder",
            showWhen: if(
              isnull(ri!tenderId),
              false(),
              {
                if(
                  contains(
                    a!forEach(
                      items: rule!CSE_CSETENDER_IDOWNER(ri!tenderId),
                      expression: fv!item
                    ),
                    tostring(loggedInUser())
                  ),
                  true,
                  false,
                  
                )
              }
            ),
            saveInto: {
              a!startProcess(
                processModel: cons!CSE_ADD_CSE_DOCUMENTS,
                processParameters: {
                  documentId: local!fileId,
                  tenderId: ri!tenderId,
                  user: tostring(loggedInUser())
                }
              ),
            },
            confirmMessage: "You sure you want to upload these files?",
            style: "PRIMARY",
            loadingIndicator:true(),
            submit:true()
          ),
        },
        align: "START"
      ),
      a!columnsLayout(
        columns: {
          a!columnLayout(
            contents: {
              a!gridLayout(
                label: "Document list",
                labelPosition: "COLLAPSED",
                headerCells: {
                  a!gridLayoutHeaderCell(label: "Document"),
                  a!gridLayoutHeaderCell(label: "Delete")
                },
                columnConfigs: {
                  a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2),
                  a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 1)
                },
                rows: {
                  a!forEach(
                    items: local!flattenfilelist,
                    expression: a!gridRowLayout(
                      contents: {
                        a!linkField(
                          labelPosition: "ABOVE",
                          links: {
                            a!documentDownloadLink(
                              label:if(rule!APN_isBlank(fv!item.documentid),
                              "",
                              if(isnull(document(fv!item.documentid,"name")),"",document((fv!item.documentid), "name"))
                              ),
                              document:
                              if(rule!APN_isBlank(fv!item.documentid),
                              {},
                              if(isnull(document(fv!item.documentid,"name")),
                              {},todocument(fv!item.documentid))
                              ),
                            )
                          }
                        ),
                        a!richTextDisplayField(
                          value: {
                            a!richTextIcon(
                              icon: "times",
                              link: {
                                a!submitLink(
                                  saveInto: {
                                    a!startProcess(
                                      processModel: cons!CSE_DOCUMENT_DELELTEBYDOCUMENT,
                                      processParameters: {
                                        deleteDocument: fv!item.documentid,
                                        deleteid: fv!item.id,
                                      },
                                      onSuccess: {
                                        a!save(
                                          target:local!flattenfilelist,
                                          value:remove(local!flattenfilelist, fv!index)
                                        ),
                                      }
                                    ),
                                    a!save(
                                      target: local!documentChildren,
                                      value: folder(1685, "documentChildren")
                                    ),
                                    a!save(
                                      target: local!UserDocuments,
                                      value: if(
                                        isnull(ri!tenderId),
                                        {},
                                        rule!CSE_USERDOCUMENTMATCH(tostring(loggedInUser()), ri!tenderId),
                                      )
                                    ),
                                    a!save(target:fv!item.documentId,value:""),
                                    /*a!save(*/
                                      /*target:local!flattenfilelist,*/
                                      /*value:remove(local!flattenfilelist, fv!index)*/
                                    /*),*/
                                    /*a!save(target:local!deleteIndex,value:local!deleteIndex+1),*/
                                  },
                                  confirmMessage: "Are you sure you want to delete this file?",
                                ),
                                a!documentDownloadLink(label:"",document:{}),
                              },
                              linkStyle: "STANDALONE",
                              showWhen: if(
                                isnull(ri!tenderId),
                                false(),
                                {
                                  if(
                                    contains(
                                      a!forEach(
                                        items: rule!CSE_CSETENDER_IDOWNER(ri!tenderId),
                                        expression: fv!item
                                      ),
                                      tostring(loggedInUser())
                                    ),
                                    true,
                                    false,
                                    
                                  )
                                }
                              ),
                              color: "NEGATIVE",
                            )
                          },
                          align: "CENTER",
                        )
                      }
                    )
                  )
                },
                selectionSaveInto: {},
                validations: {},
                shadeAlternateRows: true,
              )
            }
          )
        }
      )
    }
  )
)

  Discussion posts and replies are publicly visible