Iterating All Versions (Python)

Iterating All Versions (Python)
 1ot = impact.gui.output_toolbox
 2db = impact.active_database
 3
 4ot.clear()
 5cust = db.customers.find_by_code("ACME CORP")
 6
 7if not cust.isNone():
 8    docs = cust.documents
 9
10    if docs.isNone():
11        ot.add("No customer document support in the database")
12    else:
13        ot.add("customer document support is enabled in this database")
14        doc = None
15        try:
16            doc = docs.item("Acme Corporation Specifications.docx")
17        except Exception as exc:
18            pass
19        impact.gui.output_toolbox.add(f"Failed to create object via docs.item(): {exc}")
20
21        if not doc.isNone():
22
23            ot.add("Document: '" + doc.name + "', impact.creator: " + doc.added_by.login_id + ", Size: " + doc.size + " bytes")
24            ot.add("  IsLatestVersion: " + str(doc.is_latest_version))
25
26            for docV in doc.all_versions:
27                ot.add("version: " + docV.version.version_as_string + ", ModifiedBy: " + docV.modified_by.login_id + " at " + str(docV.modified_date_time))
28        else:
29            ot.add("Unable to locate document")
30
31else:
32    ot.add("Unable to locate a customer")