I created an interface to upload a document and i am trying to capture the document name during the upload process. Following is the piece of code for the expression rule that i have been calling in a Script task.
a!flatten( a!forEach( items: ri!attachments, expression: if( rule!app_isBlank(fv!item.attachmentType), {}, updatedictionary( dictionary: fv!item, fieldsAndValues: { recordId: ri!actionid, documentName: if( rule!app_isBlank(fv!item.documentId), null(), document(fv!item.documentId, "name") ), documentType: "", modifiedBy: "user@gmail.com", modifiedDt: now() } ) ) ) )
However, i keep getting the following error:
Expression evaluation error in rule at function a!forEach [line 2]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function 'document' [line 14]: Document Does Not Exist or has been Deleted) (Data Outputs)
I looked at some of the explanations on this issue but i am not able to figure it out. Thank you for the help.
Discussion posts and replies are publicly visible
Can you confirm that the expression rule input for "ri!attachments" is an array of the proper CDT type?
Also can you verify that in your process instance, prior to reaching that node, the "documentId" property in the PV has a proper document ID, and that none of them contain an invalid (non-null) entry like "0"?
Hi Mike,
Yes, it is of the proper CDT type. None of them have a null value.
Also, i found something interesting:
1. In the Process Model, i added a timer(1 minute) before the Script task and tested it out through the interface and it worked. File was being uploaded and data was being written to the table with the Document Name.
2. I then added this interface as a view to a "Record Type" with the same timer and everything. I then tried testing it by uploading a document and it failed with the same error. The document did not get uploaded and hence the table was not updated. The interface was not using any rule inputs (only local variables). All of my test documents are less than 5 kb in size.
Any thoughts/inputs are appreciated.
ougdp2003 said:added this interface as a view to a "Record Type"
This is not a valid configuration - newly uploaded documents get placed in a special "temporary" system folder and are not moved to their final storage location (and also aren't visible even to the "document()" function) until the form is Submitted. This must be done in a task in a process model.
got it. Thank you again for the comments. It is really helpful.