Creating Document History¶
Creating 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 history = doc.history
22
23 # by setting the ApplicationName it will be recorded against each history item
24 db.application_name = "MyApplication"
25
26 # you can define your own history operations, they should be in the range 1000+. An IDocExtender implementation
27 # can be used to provide string representations of each operatioon
28
29 ho_my_operation1 = 1000
30 ho_my_operation2 = 1001
31
32 # create some history items
33 history.add(ho_my_operation1, "Document assigned to task xxxx", empty)
34 history.add(ho_my_operation2, "Document viewed by xxxx", empty)
35
36 for item in doc.history:
37 ot.add(" " + str(item.application) + " Operation: " + str(item.operation_as_string) + " by " + str(item.modified_by.login_id) + " at " + str(item.modified_date_time))
38 if len(item.details) > 0:
39 ot.add(" " + str(item.details))
40
41 else:
42 ot.add("Unable to locate document")
43else:
44 ot.add("Unable to locate a customer")