Skip to main content
March 18, 2022
Question

Document Does Not Exist or has been Deleted

  • March 18, 2022
  • 10 replies
  • 0 views

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.

    10 replies

    gopalk2865
    Participating Frequently
    March 18, 2022

    Hi, what is the data type for documentId in your cdt? Try to wrap fv!item.documentId in tointeger() .

    March 18, 2022

    Hi,

    The document id is of integer type.

    gopalk2865
    Participating Frequently
    March 18, 2022

    Okay. Did you try to use todocument() for fv!item.documentId?

    harshitb6843
    March 18, 2022

    Hi there,

    Some quick things to check. 

    1. fv!item.documentId has a valid value.
    2. Has the document been uploaded? - Check the target folder. 
    3. Do you have access to the target folder? - Check the security
    March 18, 2022

    Yes, the document has been uploaded and it has a valid document id. For some reason, it is just not capturing the document name and writing it to the database table.

    mikes0011
    Brainy
    March 18, 2022

    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"?

    March 18, 2022

    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.

    mikes0011
    Brainy
    March 18, 2022
    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.