Creating Customer Documents

Creating Customer Documents
 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        ot.add(str(docs.count) + " documents for customer '" + cust.name + "' currently in the database")
17
18        doc = docs.add(r"C:\\Documents\\Acme Corporation Specifications.docx", "customer spec for Acme")
19
20        if not doc.isNone():
21            ot.add("Document '" + doc.name + "' successfully created")
22            ot.add("ID: " + str(doc.id))
23            ot.add("description: " + str(doc.description))
24            ot.add("Checkin-Comment: " + str(doc.comment))
25
26            ot.add("customer: " + str(doc.customer.name))
27            ot.add("Added: " + str(doc.added_date_time) + " by " + str(doc.added_by.login_id))
28            ot.add("version: " + str(doc.version.version_as_string))
29            ot.add("Size: " + str(doc.size) + " bytes")
30        else:
31            ot.add("Unable to create new document")
32
33        # must reload IDocuments
34        docs = cust.documents
35        ot.add(str(docs.count) + " documents for customer '" + cust.name + "' currently in the database")
36else:
37    ot.add("Unable to locate a customer")
38
39