I'm having an issue in upload document. The situation is that I have to disp

I'm having an issue in upload document. The situation is that I have to display the Upload Document control in a grid and once it is uploaded i need to store the document ID in DB. And if i'am again returning to this screen, and since i have already uploaded the document earlier and it is in DB, it should show the link to that document. In gridRowLayout, i am doing following:
if(
rule!APN_isBlank(ri!items[ri!index].appianDocId),
a!fileUploadField(
value: ri!items[ri!index].appianDocId,
saveInto: ri!items[ri!index].appianDocId,
target: cons!WMG_GBL_UPLOADED_DOCS_TARGET,
readOnly: true,
align: "RIGHT"
),
a!linkField(
label: "",
links: {
a!documentDownloadLink(
label: ri!items[ri!index].appianDocId,
document: ri!items[ri!index].appianDocId
)
}
)
)

Now the problem is as soon as i upload the document in the cell i...

OriginalPostID-212534

OriginalPostID-212534

  Discussion posts and replies are publicly visible

Parents
  • @Gaurav: Don't try to capture the document id as an integer (saveInto: ri!items[ri!index].appianDocId) at the point of uploading. Use a pv of type document. Upon submission of the form get the document id using document(pv!yourDocVar, "id") and store it into your CDT variable. If there are multiple documents, define document of type multiple and loop through them and get the respective integer document ids. Your retrieval logic is perfect and no change is required there.

    This approach is required because of Appian's way of handling documents. As other practitioner's mentioned, Appian will create the document in a temporary location with a temporary id at the point of upload and recreate them in the target folder (and remove the temporary document) with a new document id only at the point of form submit. If you don't use a pv variable, you will not be able to get the actual document id in anyway using the temporary document id. The temporary document id is no longer referencing any object in Appian and hence you get this error.

    Please refer the below thread and post back if you have any question
    /search?q=OriginalPostID-132941
Reply
  • @Gaurav: Don't try to capture the document id as an integer (saveInto: ri!items[ri!index].appianDocId) at the point of uploading. Use a pv of type document. Upon submission of the form get the document id using document(pv!yourDocVar, "id") and store it into your CDT variable. If there are multiple documents, define document of type multiple and loop through them and get the respective integer document ids. Your retrieval logic is perfect and no change is required there.

    This approach is required because of Appian's way of handling documents. As other practitioner's mentioned, Appian will create the document in a temporary location with a temporary id at the point of upload and recreate them in the target folder (and remove the temporary document) with a new document id only at the point of form submit. If you don't use a pv variable, you will not be able to get the actual document id in anyway using the temporary document id. The temporary document id is no longer referencing any object in Appian and hence you get this error.

    Please refer the below thread and post back if you have any question
    /search?q=OriginalPostID-132941
Children
No Data