Client Assignment & Auto-Creation
Understand how orders automatically link to clients and how new client records are created from order data
Overview
Every order in your system can be linked to a client record. This linking enables powerful features like automatic client statistics calculation, order history tracking, and revenue analytics. The system intelligently handles client linking through email matching and can automatically create new client records when needed.
How Client Linking Works
Email-Based Matching
The system uses the client email address as the unique identifier for matching orders to clients. When you create or edit an order:
- 1. The system searches for a client with the provided email address
- 2. Email comparison is case-insensitive and whitespace-trimmed
- 3. If a match is found, the order is linked to that client via clientId field
- 4. If no match is found, behavior depends on auto-creation settings
Case Insensitive: "john@example.com", "John@Example.com", and "JOHN@EXAMPLE.COM" all match the same client.
The clientId Field
Each order has an optional clientId field that references the client record:
- • With clientId: Order is linked to a client; stats are tracked
- • Without clientId: Order is standalone; no client statistics updated
- • Auto-Generated: System sets this field automatically during order creation/editing
Automatic Management: You never need to manually set clientId - the system handles it based on email matching.
Automatic Client Creation
When It Happens
A new client record is automatically created when ALL these conditions are met:
- 1. You're creating a new order (not editing)
- 2. Client email field has a value (not empty)
- 3. No existing client with that email is found
- 4. Auto-creation is not explicitly skipped
Smart Behavior: The system only creates clients when necessary, avoiding duplicates and ensuring data integrity.
What Data Gets Copied
When auto-creating a client from an order, these fields are transferred:
- • Name: From order's clientName field
- • Email: From order's clientEmail field (lowercase, trimmed)
- • Phone: From order's clientPhone field
- • Address: Complete address (street, city, state, postalCode, country)
- • Messaging Platform: From order's messagingApp field
- • Notes: From order's extraNotes field
- • Company: If provided in additional client fields (optional)
- • Preferred Language: If provided (optional)
- • Tags: If provided (optional)
Creation Notification
When a client is auto-created, you'll see two success messages:
Confirms the order was saved
Informs you a new client record was created
Verification: You can navigate to the Clients page to verify the new client was created with all the correct information.
Linking to Existing Clients
Using the Client Dropdown
The fastest way to link to an existing client is using the client selection dropdown:
- 1. Open the New Order or Edit Order modal
- 2. Click the "Select Existing Client" dropdown at the top
- 3. Search or browse for the client
- 4. Click to select - all client fields auto-populate
- 5. Complete the rest of the order form
- 6. Save the order - it's automatically linked
Time Saver: Selecting an existing client fills name, email, phone, and full address instantly, ensuring consistency.
Manual Email Entry
If you type a client's email manually instead of using the dropdown:
- • Email Matches: Order links to that client, but fields aren't auto-filled
- • Email Doesn't Match: New client created with the information you enter
Recommendation: Use the dropdown when possible to avoid typos and ensure accurate linking.
Client Statistics Updates
Automatic Recalculation
When an order is created, edited, or deleted, the linked client's statistics are automatically recalculated:
- • Total Orders: Count of all orders linked to the client
- • Completed Orders: Count of orders with "Completed" status
- • Total Spent: Sum of all completed order totals
- • Average Order Value: Total spent divided by completed orders
- • Last Order Date: Date of most recent order
Always Accurate: Statistics are recalculated from actual order data, ensuring 100% accuracy even if orders are modified or deleted.
Which Orders Count
Not all orders affect client statistics the same way:
- • Total Orders: All orders regardless of status
- • Revenue Calculations: Only orders with "Completed" status
- • Cancelled Orders: Count toward total orders but not revenue
- • Pending/Processing: Count toward total orders but not revenue (yet)
Statistics: Total Orders = 5, Completed = 3, Total Spent = $150
Changing Client Assignment
Reassigning an Order
To move an order to a different client:
- 1. Click the yellow edit icon on the order
- 2. Change the client email to the new client's email
- 3. Update client name and other fields if needed
- 4. Click "Update Order"
When you change the client email, the system:
- 1. Searches for a client with the new email
- 2. Updates the order's clientId to the new client (or null if not found)
- 3. Recalculates statistics for BOTH the old and new clients
- 4. Logs the change to activity history
Dual Updates: Both clients' statistics are automatically corrected - the old client loses the order, the new client gains it.
Unlinking an Order
To remove an order's client link entirely:
- 1. Edit the order
- 2. Clear the client email field (leave it empty)
- 3. Save the order
Result: The order becomes standalone with no clientId, and the previous client's statistics are updated to exclude it.
Updating Existing Client Data
Notes Appending
When you create an order for an existing client (matched by email) and include extra notes:
- • The order notes are appended to the client's existing notes
- • Format: "[Order: Order Title] Note content"
- • Maintains a log of order-specific notes in the client record
Existing client notes: "Prefers morning deliveries"
New order notes: "Rush order - needs by Friday"
Updated client notes: "Prefers morning deliveries\n\n[Order: Dragon Figurine]\nRush order - needs by Friday"
History Tracking: This creates a historical log of important notes from each order within the client's record.
Other Fields
For existing clients, the auto-creation process does NOT overwrite:
- • Name
- • Phone number
- • Address
- • Messaging platform
- • Company, language, or tags
To update these fields for an existing client, use the Clients page to edit the client record directly.
Best Practices
Always Provide Email: Enter client email addresses for all orders to enable automatic linking and accurate client statistics.
Use Client Dropdown: Select existing clients from the dropdown rather than typing manually to ensure consistency and avoid duplicates.
Keep Email Consistent: Use the same email format for a client across all orders (e.g., always lowercase) to ensure proper matching.
Review New Clients: After receiving the auto-creation notification, visit the Clients page to verify and complete the client profile.
Update from Clients Page: To change client details (name, phone, address), edit the client record directly rather than through orders.
Check Client Statistics: Review client profiles periodically to ensure statistics are accurate and orders are properly linked.