Adding Customers (Python)¶
Adding Customers (Python)¶
1customers = impact.active_database.customers
2
3impact.gui.output_toolbox.clear()
4impact.gui.output_toolbox.add("customer Count: " + str(customers.count))
5customer = None
6try:
7 customer = customers.add("COMTEST", "COM Test customer")
8except Exception as exc:
9 impact.gui.output_toolbox.add(f"Failed to create object via customers.add(): {exc}")
10
11if customer.isNone():
12 impact.gui.output_toolbox.add("Error: Unable to add a new customer")
13else:
14 impact.gui.output_toolbox.add("Successfully added new customer '" + customer.name + "', Active=" + str(customer.active))
15customer2 = None
16try:
17 customer2 = customers.add2("COMTEST2", "COM Test Customer2", False)
18except Exception as exc:
19 impact.gui.output_toolbox.add(f"Failed to create object via customers.add2(): {exc}")
20
21if customer.isNone():
22 impact.gui.output_toolbox.add("Error: Unable to add a new customer")
23else:
24 impact.gui.output_toolbox.add("Successfully added new customer '" + customer2.name + "', Active=" + str(customer2.active))
25
26impact.gui.output_toolbox.add("customer Count (After): " + str(customers.count))