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
Hi, what is the data type for documentId in your cdt? Try to wrap fv!item.documentId in tointeger() .
Hi,
The document id is of integer type.
Okay. Did you try to use todocument() for fv!item.documentId?
Unknown said:Did you try to use todocument() for fv!item.documentId?
that shouldn't be necessary. document() will cast an integer docid to its purposes just fine when it's called - todocument() won't really help if the id is otherwise invalid (or some other issue is happening).