Hello everyone,
I’m working with an interface grid that is prepopulated with different documents. There's also an "Add New" button that allows users to upload additional documents to the grid.
Requirement:
I’ve read in previous posts that the target attribute on the a!fileUploadField component, when set to a folder, creates a new document in that folder. If set to a document, it’s supposed to replace the existing document by creating a new version.
target
a!fileUploadField
However, I’m encountering issues with this approach. Here’s the code I’m using:
a!fileUploadField( target: if( rule!APN_isEmpty(fv!item.id), tofolder(cons!ABG_DOCUMENTS_FOLDER), local!priparedDocuments[fv!index].appianDocumentId ),
The logic is:
fv!item.id
Here, local!preparedDocuments is a CDT that holds document info, similar to a database representation of documents, and appianDocumentId refers to the document ID in Appian.
local!preparedDocuments
appianDocumentId
What's happening:
1) For newly added documents everything works OK, they appear in folder and can be downloaded
2) However, when I try to replace a pre-existing document, the old document still exists, and the new one doesn’t seem to inherit the folder (its parent is shown as [Not Visible]). As a result, the new document cannot be downloaded.
[Not Visible]
Question:
Why is this happening? Shouldn’t setting the target to the document ID in a!fileUploadField replace the old document with the new one while keeping it in the same folder as the original?
Discussion posts and replies are publicly visible
In my world, I manage all documents in a database table and just store the file itself in some folder. Then, "replacing" means to upload a new file, add a new record to the table while maintaining relevant relations, and then delete both, the old record and the old file.
Hi Stefan,
Yes, that would be a viable workaround, and we do have a similar document representation in the database. However, I was aiming for a more elegant solution, as it seemed from the documentation and previous discussions that we could simply replace or create a new version of the already existing files using the a!fileUploadField component.
I’m just curious as to why this approach isn’t working as expected.
Not sure. I do not remember whether I have aver tried that. I suggest to implement a tiny simplified test.