Iterating Document History

Iterating Document History
 1ot = impact.gui.output_toolbox
 2db = impact.active_database
 3
 4ot.clear()
 5
 6cust = db.customers.find_by_code("ACME CORP")
 7
 8if cust is not None:
 9    docs = cust.documents
10
11    if docs is None:
12        ot.add("No customer document support in the database")
13    else:
14        ot.add("customer document support is enabled in this database")
15
16        doc = docs.item("Acme Corporation Specifications.docx")
17
18        if not doc.isNone():
19            ot.add("Document: '" + doc.name + "', impact.creator: " + str(doc.added_by.login_id) + ", Size: " + str(doc.size) + " bytes")
20
21            ot.add("Document history for this specific document version " + str(doc.version.version_as_string))
22            for item in doc.history:
23                ot.add("  " + str(item.application) + " Operation: " + str(item.operation_as_string) + " by " + str(item.modified_by.login_id) + " at " + str(item.modified_date_time))
24                if len(item.details) > 0:
25                    ot.add("    " + str(item.details))
26
27            ot.add("Document history for all document versions in the series")
28            for item in doc.series_history:
29                ot.add("  " + str(item.application) + " Operation for version " + str(item.document.version.version_as_string) + ": " + str(item.operation_as_string) + " by " + str(item.modified_by.login_id) + " at " + str(item.modified_date_time))
30                if len(item.details) > 0:
31                    ot.add("    " + str(item.details))
32
33        else:
34            ot.add("Unable to locate document")
35else:
36    ot.add("Unable to locate a customer")
37
38