Creating Contact Documents

Creating Contact 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    contact = cust.contacts.item("Rob")
10
11    if not contact.isNone():
12        docs = contact.documents
13
14        if docs is None:
15            ot.add("No contact document support in the database")
16        else:
17            ot.add("Contact document support is enabled in this database")
18
19            ot.add(str(docs.count) + " documents for contact '" + contact.full_name + "' currently in the database")
20
21            doc = docs.add(r"C:\\Documents\\Contact Preferences.docx", "Contact preferences")
22
23            if not doc.isNone():
24                ot.add("Document '" + doc.name + "' successfully created")
25                ot.add("description: " + str(doc.description))
26                ot.add("Checkin-Comment '" + str(doc.comment))
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 = contact.documents
35            ot.add(str(docs.count) + " documents for contact '" + contact.full_name + "' currently in the database")
36    else:
37        ot.add("Unable to locate contact")
38else:
39    ot.add("Unable to locate customer")
40
41