Validate document ID

Is there a way to validate an Appian document ID before trying to use the document() function on it?  document() will fail if passed an invalid Appian document, and todocument() will return a document type even if the ID is not a valid Appian document ID

 Discussion posts and replies are publicly visible