Question
report file doesn't exist when delete in editable grid
I am trying to delete a row in a editable grid by "times icon.
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!fileList: a!refreshVariable(
a!forEach(
items: local!documentChildren,
expression: a!localVariables(
local!documentChild: fv!item,
a!forEach(
items: local!UserDocuments,
expression: if(
document(local!documentChild, "name") = document(fv!item.documentid, "name"),
if(
document(local!documentChild,"id")=tointeger(fv!item.documentid),
fv!item,{}
),
{}
)
)
)
)
),
local!flattenfilelist: a!flatten(local!fileList),
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: document((fv!item.documentid), "name"),
document: 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,
}
),
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: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?"
)
},
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,
)
}
)
}
)
}
)
)
If i click the first time of the times icon it is good, it delete the file and delete the row as i expected, but if i click twice it disappear, but the files is definitely exists in the folder why it report
"Interface Definition: Expression evaluation error at function a!forEach [line 176]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function 'document' [line 184]: Document Does Not Exist or has been Deleted"?
