How to check if documents exist?

Certified Associate Developer

Hi there, I am trying to create an expression rule that returns true if a document is not null, and has an ID attached to it. The expression rule is used to determine an XOR node to go to the document deletion node to delete the document if it exists, or to move to the end node if it has already been deleted. Right now, I am using a plugin isObjectExists() and it does work correctly but my supervisor wants me to improve the code to not use that plugin, any ideas for what to do?

Here is the expression rule I created, it currently works how I want it to but I want to avoid using the plugin, any help is appreciated!

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Lead Developer
    in reply to Chris

    but what if a nonsense ID is passed in?  wouldn't it still render the same, and return a fake result?

    (This would also apply when a document has already been deleted, but the process instance is still passing around references to its ID, as far as I know.)

  • In those situations, I seem to have issues in other areas first - such as when a document is stored in a PV, but it is deleted via Related Action and the PV is not updated/cleared - I get forms not loading at all, etc (if they reference the document). 

    Expression evaluation error [evaluation ID = TPWUJ] in rule 'form_xyz' at function a!fileUploadField_17r1 [line 142]: Invalid Content ID

    The string check isn't perfect, but has worked for all my use cases so far Slight smile