Question
Is it possible to delete a document from a batch that did not match a document definition or an unknown document?
Answer
Yes, it is possible using Automatic or Script Stage under Workflow in Project Properties or Batch Type. However, the script syntax may vary per version. See below sample script below for versions 12.0.3.x and 12.0.4.x.
12.0.3.x
int x = Documents.Count; for (int i = x - 1; i>=0 ; i--) { string defName = Documents[i].DefinitionName; FCTools.ShowMessage("Checking Doc: " + (i + 1) + " Definition: " + defName); if(string.IsNullOrEmpty(defName)) { FCTools.ShowMessage("Document Delete"); Documents[i].Batch.DeleteDocument(Documents[i]); } }12.0.4.x
foreach (IDocument doc in Batch.Documents) { FCTools.ShowMessage(doc.DefinitionName); if (doc.DefinitionName == "") { Batch.DeleteDocument(doc); } }Warning!: Please verify functionality before deployment to avoid unexpected issues.