Customer records
Customer records represent the organizations or people that receive support. They connect contacts to tickets so agents can see customer context while portal users see only the customer information and ticket history allowed by their membership.
Customer record model
Record identity and membership
An HD Customer is the support-facing record for a company, individual, or partnership. It stores the customer name, type, country, domain, image, and an optional primary contact. Its contact list is made of HD Customer Member rows that link Contact records to the customer and mark each member as either a customer or a customer manager. The primary contact must be one of these members and is treated as a manager.
The primary contact supplies the record email and mobile number. This keeps the customer record useful as a summary while the linked contact remains the source for personal details. The customer record also carries a hidden link to a matching ERPNext customer when ERPNext sync is active.
References: helpdesk/…/hd_customer.json• L25-110 helpdesk/…/hd_customer.json• L122-190 helpdesk/…/hd_customer.py• L78-145
External customer link
When ERPNext sync is active, each helpdesk customer can have a matching ERPNext customer. The link keeps the support record and the ERP customer aligned while treating sync metadata as separate from a user's customer changes.
References: helpdesk/…/hd_customer.py• L413-471
Customer relationships
The relationship helper resolves a user or contact to all linked customers. The same relationship drives customer visibility and ticket visibility, so a contact can belong to more than one customer without losing the membership context for each one.
The customer link on a ticket is separate from the contact link. The contact identifies the person who raised or owns the request. The customer identifies the organization or customer account that owns the support relationship. See Customer and contact relationships for the wider relationship model and Contact management for contact-side operations.
References: helpdesk/utils.py• L104-133 helpdesk/…/hd_ticket.json• L321-337
Customer record APIs
Record creation
The customer API creates the customer record and can create or reuse a primary contact in the same request. The primary contact becomes a manager member. When that contact has no linked user, the API sends an invitation; when a user already exists, it links the contact without sending a duplicate invitation.
The primary entry point is helpdesk/…/customer.py. The desk uses it from the customer creation dialog, then opens the new customer record and reports whether an invitation was sent.
References: helpdesk/…/customer.py• L51-101 helpdesk/…/hd_customer.py• L317-345 helpdesk/…/test_hd_customer.py• L249-361
Member operations
Customer member operations accept a contact name or an email address. A contact with a linked user is added directly. A contact without a user enters the invitation flow unless the caller explicitly disables invitations, in which case an existing contact can still be added without creating a user.
The APIs also support organization-level invitations, role changes, member removal, invitation cancellation, and logo updates. These actions are limited by customer-manager status, agent-manager status, and the matching helpdesk settings. Organization managers can search for eligible portal users on the organization's private email domain; agents and existing or pending members are excluded from those suggestions.
The customer record exposes member details for the agent desk. That response combines contact data with the member role, primary state, recent activity, and the count of open or paused tickets linked through either the contact or the ticket raiser. Portal organization responses expose a smaller member view and include recent activity or pending invitations only when the caller has manager access.
References: helpdesk/…/hd_customer.py• L187-216 helpdesk/…/hd_customer.py• L265-367 helpdesk/…/customer.py• L141-197 helpdesk/…/customer.py• L200-363 helpdesk/…/customer.py• L415-465
Record deletion
Deleting a customer requires a choice about its linked tickets. The destructive choice removes the tickets. The preserving choice keeps the tickets but clears their customer link. Related pending invitations also lose their customer link.
The API checks both customer permission and the ticket permission needed for the selected outcome. The customer page presents this choice before it sends the delete request.
References: helpdesk/…/customer.py• L104-115 helpdesk/…/hd_customer.py• L458-495 desk/…/Customer.vue• L81-98
Agent desk views
Customer list
The customer list is the agent entry point for finding customer records. It presents the customer name, type, primary contact email and mobile number, creation time, and image. Selecting a row opens the customer detail view, while the create action starts the record and optional primary-contact flow.
The list is backed by the HD Customer access rules. Agents can search and view the customer set available to the agent role; non-agent users receive only records linked to their own contact membership.
References: desk/…/Customers.vue• L2-24 desk/…/Customers.vue• L46-81 helpdesk/…/hd_customer.py• L32-76 helpdesk/…/hd_customer.py• L497-525
Customer detail view
The detail view brings together customer identity, support performance, tickets, and contacts. Agents can use the ticket tab to search by ticket ID or subject and filter by status, priority, and member contact. The contacts tab shows member role and activity context and provides the invitation path when the current user has the required permission.
The page also shows ticket measures for the customer, including feedback, service-level failures, first response time, and resolution time. These measures describe support work for the customer without changing the customer record itself. The ticket tab always starts with the current customer as its scope, while the contact filter narrows that scope to members of the customer.
References: desk/…/Customer.vue• L14-77 desk/…/Customer.vue• L161-175 desk/…/Customer.vue• L218-253 desk/…/CustomerContactTab.vue• L1-46 desk/…/TicketStats.vue• L1-20
Customer-linked tickets
Ticket association
A ticket can link to both a contact and an HD Customer. When customer auto-linking is enabled, a ticket with one customer linked to its contact receives that customer automatically. If the contact belongs to several customers, a portal user must choose the customer so the request is not assigned to the wrong account.
Agents can work with the customer link directly. Non-agent changes must keep the selected customer within the contact's memberships. This rule keeps a portal user's ticket inside the customer relationships that user is allowed to represent.
The relationship can be viewed as a path from a person to an account and then to the account's support history:
flowchart LR
Contact[Contact] --> Member[Customer membership]
Member --> Customer[HD Customer]
Contact --> Ticket[HD Ticket]
Customer --> Ticket
Ticket --> Agent[Agent desk context]
Ticket --> Portal[Customer portal view]
References: helpdesk/…/hd_ticket.py• L317-363 helpdesk/utils.py• L104-133 helpdesk/…/hd_ticket.json• L327-337
Customer ticket views
The customer detail page loads tickets with the customer link as its base filter. It can add a member-contact filter and lets the user search ticket IDs or subjects. Each row opens the ticket workspace, where the ticket's contact and customer context remain available.
The ticket list still applies ticket permission rules. The customer page does not grant access by itself; it asks the ticket system for records that the current user may read.
See Ticket management for the complete ticket lifecycle and agent workspace.
References: desk/…/Customer.vue• L65-75 desk/…/Customer.vue• L241-252 desk/…/TicketsTab.vue• L7-27 desk/…/TicketsTab.vue• L283-307 helpdesk/…/hd_ticket.py• L1335-1455
Permission-aware customer information
Agent access
Agents can read customer records across the helpdesk. The agent customer API returns member contact details and support context, including primary and manager markers, last activity, and pending-ticket counts. Customer edits and member changes still use separate permission checks.
Customer managers have broader access only for the organizations they manage. The manager role follows the membership row, so a person who manages one customer does not gain manager access to another customer where they are only a member. Agent managers can manage organizations through the same manager checks.
References: helpdesk/…/hd_customer.json• L148-179 helpdesk/…/hd_customer.py• L187-216 helpdesk/…/hd_customer.py• L511-532 helpdesk/…/customer.py• L483-507 helpdesk/…/test_hd_customer.py• L408-460
Portal organization views
Portal users receive a session account summary with the organizations linked to their contact. Each organization includes the user's role plus member and readable-ticket counts. An organization detail response includes basic customer identity and member information for anyone who can read that customer.
Manager-only data is added only when the user manages that organization or is an agent manager. Depending on the helpdesk settings, this includes member activity, pending invitations, eligible invitee search, invitations, role changes, removals, and logo updates. A public email domain does not provide invite suggestions because it cannot safely identify the organization.
References: helpdesk/…/customer.py• L118-161 helpdesk/…/customer.py• L164-197 helpdesk/…/customer.py• L365-465 helpdesk/…/hd_customer.py• L497-532
Portal ticket access
Portal users do not receive the agent customer desk. Their ticket access follows customer membership: a regular customer member can see tickets tied directly to that member, while a customer manager can see the tickets raised for the managed customer.
Portal ticket detail data includes safe contact and ticket context. Ticket template fields marked hide_from_customer are left out of the portal detail view, and assignees are shown without agent presence details. A non-agent can raise a ticket only for the contact owned by the current session, which prevents one portal user from acting as another contact.
Customer portal roles are created without desk access and use the helpdesk portal as their home. An agent manager can start a background migration that promotes all customer contacts to managers and restores organization-wide ticket visibility for those members.
References: helpdesk/…/hd_ticket.py• L279-315 helpdesk/…/hd_ticket.py• L1396-1455 helpdesk/…/api.py• L39-159 helpdesk/…/api.py• L750-777 desk/…/TicketCustomerTemplateFields.vue• L36-51 helpdesk/…/customer_portal_notice.py• L6-29 helpdesk/…/customer_portal_notice.py• L31-110
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to customer membership roles must stay aligned with
HD Customerrecord permissions and the ticket visibility query. A change in one area can silently expose or hide a customer's ticket history. - Changes to customer organization responses must stay aligned with both the agent detail view and the portal account and organization views. Member roles, counts, activity, and invitations have different visibility rules.
- Changes to customer invitations must preserve the domain privacy filter, the manager settings, the batch and rate limits, and the distinction between existing members, pending invitations, disabled users, and new invitees.
- Changes to the customer link or contact auto-link rule must be checked against ticket creation validation, customer ticket filters, and the member ticket counts shown on the detail page.
- Changes to customer deletion must preserve the contract between the delete dialog,
delete_customer, and the selected ticket outcome: delete all linked tickets or detach them without deleting them. - Changes to portal ticket fields must be reflected in both the ticket detail API and the
hide_from_customerfiltering used by the portal UI. - Changes to ERPNext customer sync must preserve the link between the support record and its ERPNext customer without presenting sync backfills as user edits.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A portal user is not a member of the requested customer | The customer record is not visible to that user | Customer record permission checks limit non-agents to their memberships |
| A customer manager acts on an organization without the matching manager setting | The member or organization change is rejected | Validate both the organization manager relationship and the helpdesk setting |
| A contact belongs to more than one customer and a portal ticket has no customer choice | Ticket creation fails instead of selecting an unsafe account | Require a customer selection for multi-customer portal contacts |
| A customer is deleted with the destructive option | Every ticket linked to that customer is deleted | Confirm the ticket choice and require the matching ticket permission |
| A portal user changes a ticket contact to another person | The update is rejected | Validate the contact against the current session user |
| A portal response includes a field marked for agents only | Customer users could see internal ticket data | Filter template fields marked hide_from_customer before rendering portal details |
| An organization uses a public email domain for invite suggestions | Unrelated portal users could be exposed as possible members | Return no suggestions for public or missing domains |
| ERPNext sync backfills the linked customer reference as a normal record edit | The customer appears to change even though only sync metadata changed | Keep the external link update separate from the customer record's modified timestamp |
Key files
| File | Why to read it |
|---|---|
| helpdesk/…/hd_customer.py | Defines customer membership behavior, member data, ticket cleanup, external customer sync, and record-level access |
| helpdesk/…/hd_customer.json | Defines the customer identity fields, primary contact, member table, and role permissions |
| helpdesk/…/hd_customer_member.json | Defines the contact membership and manager marker used by access rules |
| helpdesk/…/customer.py | Defines customer creation, deletion, portal organization data, invitations, and member management |
| desk/…/Customers.vue | Shows the agent entry point for customer search and record creation |
| desk/…/Customer.vue | Shows how customer identity, ticket history, contacts, and ticket measures meet in one view |
| desk/…/TicketsTab.vue | Shows the customer-scoped ticket search and filter experience |
| desk/…/CustomerContactTab.vue | Shows the customer member view and invitation entry point |
| helpdesk/…/hd_ticket.py | Defines how ticket links to customers and contacts affect visibility and validation |
| helpdesk/…/api.py | Defines permission-aware ticket detail data for agents and portal users |
| helpdesk/…/customer_portal_notice.py | Shows the controlled migration path from member-only to manager-level portal visibility |
| helpdesk/…/test_hd_customer.py | Verifies invitation, role, membership, deletion, and customer permission contracts |