One prospect or deal moving through a funnel, holding who it is for, where it has got to, and what it is worth. A lead belongs to an admin organisation and to a funnel repository at a particular branch. Its current goal is the goal the funnel is currently trying to have it reach; once that goal is attained the lead moves on to wait for the next one. The customer may be a known Profile, or, before the customer has been identified, just a tracking id plus captured first name, surname, email and phone. Roles on the lead are read through the participants API rather than the individual legacy fields. Deleting a lead that has a linked profile is a soft delete, recorded in deletedDate and deletedBy, so a lead can still exist in the database after it has been deleted.
Group: Database Entities
Implements: Serializable, Relational
Properties
| Property | Returns | Description |
|---|---|---|
| acceptedQuote | Quote | The accepted quote from the proposal recorded on this lead's "proposalId" custom field, if any. Looks up the proposal and its quotes from the database each call. Null if there is no proposal id set, the proposal cannot be found, it does not belong to this lead, or none of its quotes have been accepted. |
| adminDomain | Organisation | The organisation that owns this lead, ie the tenant running the funnel. Never null. |
| allFieldValues | Map<String,String> | All custom field values set on this lead, as a name-to-value map in field order. Empty if no custom fields have been set. |
| allParticipants | List<LeadParticipant> | The full set of role-based participants on this lead: a synthetic, transient entry for each non-null legacy field (ROLE_CUSTOMER/ROLE_CUSTOMER_ORG/ROLE_ASSIGNED_ORG/ROLE_OWNER), plus the persisted rows for any custom roles. Callers get a single uniform list regardless of which mechanism backs a given role. |
| assetId | String | For a lead that relates to a specific asset, the uniqueId of that asset. Null for leads not associated with an asset. |
| assignedToGroup | Group | The group currently assigned to handle this lead, if any. |
| assignedToOrg | Organisation | The sub-organisation assigned to handle this lead, if any. |
| assignedToProfile | Profile | The team member assigned to handle this lead, if any. Also referred to as the lead's owner. |
| calendarEvents | List<CalEvent> | The events on the lead's linked profile's own calendar, looked up from the database each call. Empty if the lead has no linked profile. |
| cancelled | boolean | Whether this lead has been cancelled, ie lost rather than won. |
| cancelledReason | String | A code indicating the general reason this lead was lost. Null unless the lead is cancelled. |
| ccList | String | A comma-separated list of additional recipients to include on communications about this lead, up to 20000 characters. May be null. |
| closedDate | Date | The date this lead was finished, whether won or lost. Null while the lead is still active. |
| company | String | The company name captured for this lead when it cannot yet be linked to a full Organisation. May be null. |
| completedProcessingAt | Date | When timer processing for the current goal was successfully completed. Null while processing is still pending or in progress. |
| createDate | Date | When this lead was created. Never null once persisted. |
| createdBy | Profile | The user who created this lead, if it was created by a team member rather than automatically from an inbound enquiry. May be null. |
| currentGoal | String | The name of the goal the lead is currently trying to attain. Once attained, processing moves on to the next goal in the funnel. |
| dealAmount | BigDecimal | The expected sale value of this deal. May be null if not yet estimated. |
| deletedBy | Profile | The user who deleted this lead, if it has been soft-deleted. |
| deletedDate | Date | When this lead was soft-deleted. Null for a lead that has not been deleted. |
| description | String | A free-text description of this lead, up to 20000 characters. May be null. |
String | The email address captured for this lead when it cannot yet be linked to a full customer Profile. Null once the lead has a linked profile. | |
| engagementScore | Double | A score based on activity, ie behavioural factors such as how the lead's contact has engaged. May be null if not yet calculated - see getScoreDate for when it was last calculated. |
| estimatedHours | Double | The estimated hours of work required for this lead. May be null if not estimated. |
| fields | NvSet | The set of custom field name/value pairs stored against this lead. May be null if no custom fields have been set - use getFieldValue/setFieldValue rather than manipulating this directly. |
| files | List<LeadFile> | The files attached to this lead. May be null or empty if none have been attached. |
| firstName | String | The first name captured for this lead when it cannot yet be linked to a full customer Profile. Null once the lead has a linked profile. |
| formattedName | String | A display name for the lead, equivalent to formattedName truncated to 35 characters. |
| formattedTitle | String | A display title for the lead: its description if set, otherwise its funnel's title, falling back to the funnel's name. Null if none of those are available. |
| funnel | FunnelRepository | The funnel this lead is progressing through. Never null for a lead created via Lead.create. |
| funnelBranch | String | The name of the funnel branch/version this lead is connected to, fixing the process definition it follows even if the funnel is later edited. |
| funnelEdms | List<FunnelEdm> | The funnel EDM (email direct marketing) sends recorded against this lead, looked up from the database each call. |
| id | long | The database identifier for this lead. Assigned on first save and never changes. |
| initialContactDate | Date | When the contact first requested information, used as the baseline for measuring response time. May be null if not recorded. |
| jobTitle | String | The job title captured for this lead's contact. May be null. |
| lastAttainedDate | Date | The date and time the most recent goal was attained. May be null if the lead has not yet attained a goal. |
| lastAttainedGoal | String | The name of the most recently attained goal. May be null if no goal has been attained yet. |
| lastContactRequest | ContactRequest | The most recent contact request raised by this lead's profile, looked up from the database each call. Null if the lead has no profile or the profile has no contact requests. |
| leadNum | String | A user-controlled identifier for the lead, intended to be unique within the owning organisation. Nullable, up to LEAD_NUM_MAX_LENGTH characters. |
| leadProducts | List<Product> | The products associated with this lead, looked up from the database each call. Empty if no products have been added. |
| leadProductsList | List<LeadProduct> | The LeadProduct join rows for this lead, each carrying a product and its quantity, looked up from the database each call. Empty if no products have been added. |
| leadTeams | List<Organisation> | The organisations relevant to this lead: its assigned org if set, plus its customer organisation, falling back to the admin domain if there is no customer organisation. |
| modifiedDate | Date | When this lead was last modified. |
| mostRecentTask | Task | The most recently created task linked to this lead, looked up from the database each call. Null if the lead has no tasks. |
| numAttempts | Integer | The number of times timer processing has been attempted for this lead's current goal. Null before the first attempt. |
| participants | List<LeadParticipant> | The persisted custom-role participant assignments for this lead. Does not include the 4 legacy roles (customer, customer org, assigned org, owner) - use getAllParticipants for the merged view that includes those. |
| phone | String | The phone number captured for this lead when it cannot yet be linked to a full customer Profile. Null once the lead has a linked profile. |
| processingStartedAt | Date | When timer processing last began for this lead. Set and committed immediately a process takes the lead, so other processes can see it is locked for processing until timeoutMins has elapsed. Null if no processing attempt is in progress. |
| profile | Profile | The customer profile for this lead, if any. Null when the lead has not yet been linked to a known profile, for example while it is only identified by a tracking id or by captured first name/email/phone details. |
| profileScore | Double | A score based on the lead's profile, ie demographic data. May be null if not yet calculated - see getScoreDate for when it was last calculated. |
| scoreDate | Date | When getEngagementScore and getProfileScore were last calculated. Null if scores have not yet been calculated. |
| source | String | Where this lead originated from, for example facebook or googleAd. May be null if the source was not recorded. |
| sourceLead | Lead | The lead this one was derived or cloned from, if any. |
| stageName | String | The name of the stage this lead is currently in. A stage aggregates one or more goals to give a coarser view of progress through the funnel. |
| status | String | A simple status label for the lead: Active while still in progress, Won once closed successfully, or Lost if cancelled. |
| summary | String | A short human-readable summary of the lead, combining its lead number, title, deal amount, and cancelled/closed status into a single semicolon-separated string. Fields that are not set are omitted, so the result may be empty. |
| surName | String | The surname captured for this lead when it cannot yet be linked to a full customer Profile. Null once the lead has a linked profile. |
| timerDate | Date | The date and time at which the current goal times out and the lead becomes due for timer processing. May be null if the current goal has no timeout. |
| title | String | The lead's title, a short free-text label. May be null. |
| trackingId | String | The anonymous tracking id used to correlate this lead with a browser or device before the customer's profile is known, for example from a cookie set on a shared computer. May be null. |
| transitions | List<LeadJourneyTransition> | The recorded journey transitions for this lead, ie the history of goal/stage changes it has been through, looked up from the database each call. |
Methods
rowId() · getId() · getAdminDomain() · getLeadNum() · getTrackingId() · getSurName() · getFirstName() · getPhone() · getEmail() · getProfile() · getCreateDate() · getCreatedBy() · getModifiedDate() · getInitialContactDate() · getLastAttainedDate() · getFunnel() · getFunnelBranch() · getCurrentGoal() · getLastAttainedGoal() · getStageName() · getAssignedToGroup() · getAssignedToOrg() · getAssignedToProfile() · getDealAmount() · isCancelled() · getClosedDate() · getDescription() · getSource() · getFiles() · getParticipants() · getAllParticipants() · getParticipant(String roleKey) · getParticipants(String roleKey) · getFields() · getCancelledReason() · getJobTitle() · getCompany() · getCcList() · getTimerDate() · getNumAttempts() · getProcessingStartedAt() · getCompletedProcessingAt() · getSourceLead() · getDeletedBy() · getDeletedDate() · getEstimatedHours() · getEngagementScore() · getProfileScore() · getScoreDate() · getAssetId() · newTask(Date now) · firstNote() · lastNote() · getFile(String name) · getFile(Long id) · getFieldValue(String name) · setFieldValue(String name, String value) · deleted() · getLastContactRequest() · tasks() · getMostRecentTask() · getAllFieldValues() · getStatus() · getAcceptedQuote() · getCalendarEvents() · getFunnelEdms() · leadFile(String att) · leadFile(Long id) · getFormattedTitle() · addProduct(Product p) · addProduct(Product p, BigDecimal quantity) · removeProduct(Product p) · removeLeadProduct(Long id, Organisation org) · removeAllProducts() · getLeadProducts() · getLeadProductsList() · getTitle() · getFormattedName() · formattedName(int maxLength) · hoursWorked() · is(String type) · isStatus(LeadStatusType type) · getTransitions() · getLeadTeams() · getSummary()
rowId()
Returns: Long
The lead's id, exposed under the common Relational name so generic code can identify any related row the same way.
getId()
Returns: long
The database identifier for this lead. Assigned on first save and never changes.
getAdminDomain()
Returns: Organisation
The organisation that owns this lead, ie the tenant running the funnel. Never null.
getLeadNum()
Returns: String
A user-controlled identifier for the lead, intended to be unique within the owning organisation. Nullable, up to LEAD_NUM_MAX_LENGTH characters.
getTrackingId()
Returns: String
The anonymous tracking id used to correlate this lead with a browser or device before the customer's profile is known, for example from a cookie set on a shared computer. May be null.
getSurName()
Returns: String
The surname captured for this lead when it cannot yet be linked to a full customer Profile. Null once the lead has a linked profile.
getFirstName()
Returns: String
The first name captured for this lead when it cannot yet be linked to a full customer Profile. Null once the lead has a linked profile.
getPhone()
Returns: String
The phone number captured for this lead when it cannot yet be linked to a full customer Profile. Null once the lead has a linked profile.
getEmail()
Returns: String
The email address captured for this lead when it cannot yet be linked to a full customer Profile. Null once the lead has a linked profile.
getProfile()
Returns: Profile
The customer profile for this lead, if any. Null when the lead has not yet been linked to a known profile, for example while it is only identified by a tracking id or by captured first name/email/phone details.
getCreateDate()
Returns: Date
When this lead was created. Never null once persisted.
getCreatedBy()
Returns: Profile
The user who created this lead, if it was created by a team member rather than automatically from an inbound enquiry. May be null.
getModifiedDate()
Returns: Date
When this lead was last modified.
getInitialContactDate()
Returns: Date
When the contact first requested information, used as the baseline for measuring response time. May be null if not recorded.
getLastAttainedDate()
Returns: Date
The date and time the most recent goal was attained. May be null if the lead has not yet attained a goal.
getFunnel()
Returns: FunnelRepository
The funnel this lead is progressing through. Never null for a lead created via Lead.create.
getFunnelBranch()
Returns: String
The name of the funnel branch/version this lead is connected to, fixing the process definition it follows even if the funnel is later edited.
getCurrentGoal()
Returns: String
The name of the goal the lead is currently trying to attain. Once attained, processing moves on to the next goal in the funnel.
getLastAttainedGoal()
Returns: String
The name of the most recently attained goal. May be null if no goal has been attained yet.
getStageName()
Returns: String
The name of the stage this lead is currently in. A stage aggregates one or more goals to give a coarser view of progress through the funnel.
getAssignedToGroup()
Returns: Group
The group currently assigned to handle this lead, if any.
getAssignedToOrg()
Returns: Organisation
The sub-organisation assigned to handle this lead, if any.
getAssignedToProfile()
Returns: Profile
The team member assigned to handle this lead, if any. Also referred to as the lead's owner.
getDealAmount()
Returns: BigDecimal
The expected sale value of this deal. May be null if not yet estimated.
isCancelled()
Returns: boolean
Whether this lead has been cancelled, ie lost rather than won.
getClosedDate()
Returns: Date
The date this lead was finished, whether won or lost. Null while the lead is still active.
getDescription()
Returns: String
A free-text description of this lead, up to 20000 characters. May be null.
getSource()
Returns: String
Where this lead originated from, for example facebook or googleAd. May be null if the source was not recorded.
getFiles()
Returns: List<LeadFile>
The files attached to this lead. May be null or empty if none have been attached.
getParticipants()
Returns: List<LeadParticipant>
The persisted custom-role participant assignments for this lead. Does not include the 4 legacy roles (customer, customer org, assigned org, owner) - use getAllParticipants for the merged view that includes those.
getAllParticipants()
Returns: List<LeadParticipant>
The full set of role-based participants on this lead: a synthetic, transient entry for each non-null legacy field (ROLE_CUSTOMER/ROLE_CUSTOMER_ORG/ROLE_ASSIGNED_ORG/ROLE_OWNER), plus the persisted rows for any custom roles. Callers get a single uniform list regardless of which mechanism backs a given role.
getParticipant(String roleKey)
Returns: LeadParticipant
The first participant filling the given role - use for the 4 legacy roles, or any custom role which isn't multi-valued.
| Parameter | Description |
|---|---|
roleKey | the role to look up |
getParticipants(String roleKey)
Returns: List<LeadParticipant>
All participants filling the given role - use for multi-valued custom roles.
| Parameter | Description |
|---|---|
roleKey | the role to look up |
getFields()
Returns: NvSet
The set of custom field name/value pairs stored against this lead. May be null if no custom fields have been set - use getFieldValue/setFieldValue rather than manipulating this directly.
getCancelledReason()
Returns: String
A code indicating the general reason this lead was lost. Null unless the lead is cancelled.
getJobTitle()
Returns: String
The job title captured for this lead's contact. May be null.
getCompany()
Returns: String
The company name captured for this lead when it cannot yet be linked to a full Organisation. May be null.
getCcList()
Returns: String
A comma-separated list of additional recipients to include on communications about this lead, up to 20000 characters. May be null.
getTimerDate()
Returns: Date
The date and time at which the current goal times out and the lead becomes due for timer processing. May be null if the current goal has no timeout.
getNumAttempts()
Returns: Integer
The number of times timer processing has been attempted for this lead's current goal. Null before the first attempt.
getProcessingStartedAt()
Returns: Date
When timer processing last began for this lead. Set and committed immediately a process takes the lead, so other processes can see it is locked for processing until timeoutMins has elapsed. Null if no processing attempt is in progress.
getCompletedProcessingAt()
Returns: Date
When timer processing for the current goal was successfully completed. Null while processing is still pending or in progress.
getSourceLead()
Returns: Lead
The lead this one was derived or cloned from, if any.
getDeletedBy()
Returns: Profile
The user who deleted this lead, if it has been soft-deleted.
getDeletedDate()
Returns: Date
When this lead was soft-deleted. Null for a lead that has not been deleted.
getEstimatedHours()
Returns: Double
The estimated hours of work required for this lead. May be null if not estimated.
getEngagementScore()
Returns: Double
A score based on activity, ie behavioural factors such as how the lead's contact has engaged. May be null if not yet calculated - see getScoreDate for when it was last calculated.
getProfileScore()
Returns: Double
A score based on the lead's profile, ie demographic data. May be null if not yet calculated - see getScoreDate for when it was last calculated.
getScoreDate()
Returns: Date
When getEngagementScore and getProfileScore were last calculated. Null if scores have not yet been calculated.
getAssetId()
Returns: String
For a lead that relates to a specific asset, the uniqueId of that asset. Null for leads not associated with an asset.
newTask(Date now)
Returns: Task
Builds a new, unsaved Task pre-populated with this lead's admin domain, funnel and profile, and linked back to this lead. The caller is responsible for setting any remaining fields (such as due date and assignee) and saving it.
| Parameter | Description |
|---|---|
now | the creation timestamp to set on the new task |
firstNote()
Returns: LeadNote
Loads every note on this lead and returns the earliest one by creation date. Null if the lead has no notes. Hits the database on each call.
lastNote()
Returns: LeadNote
Loads every note on this lead and returns the most recent one by creation date. Null if the lead has no notes. Hits the database on each call.
getFile(String name)
Returns: LeadFile
The file attached to this lead with the given name, matched exactly and case sensitively. Null if the lead has no files or none matches.
| Parameter | Description |
|---|---|
name | the file name to match |
getFile(Long id)
Returns: LeadFile
The file attached to this lead with the given database id. Null if the lead has no files or none matches.
| Parameter | Description |
|---|---|
id | the id of the lead file to find |
getFieldValue(String name)
Returns: String
The value of one custom field on this lead, read from the lead's field set. Null if the lead has no field set, or if that field has not been given a value.
| Parameter | Description |
|---|---|
name | the name of the custom field to read |
setFieldValue(String name, String value)
Returns: void
Sets one custom field on this lead and saves it, using the current session. The names dealAmount and title are special cased and write to the lead's own columns rather than to the field set. A null value removes the field. Creates the lead's field set on first use.
| Parameter | Description |
|---|---|
name | the name of the custom field to write, or dealAmount or title for the lead's own columns |
value | the new value, or null to remove the field |
deleted()
Returns: boolean
Whether this lead has been soft deleted, ie whether a deleted date has been recorded against it. A soft deleted lead is still present in the database, so most queries must exclude it explicitly.
getLastContactRequest()
Returns: ContactRequest
The most recent contact request raised by this lead's profile, looked up from the database each call. Null if the lead has no profile or the profile has no contact requests.
tasks()
Returns: List<Task>
All tasks recorded against this lead, open and closed, in the order the task lookup returns them. Hits the database on each call.
getMostRecentTask()
Returns: Task
The most recently created task linked to this lead, looked up from the database each call. Null if the lead has no tasks.
getAllFieldValues()
Returns: Map<String,String>
All custom field values set on this lead, as a name-to-value map in field order. Empty if no custom fields have been set.
getStatus()
Returns: String
A simple status label for the lead: Active while still in progress, Won once closed successfully, or Lost if cancelled.
getAcceptedQuote()
Returns: Quote
The accepted quote from the proposal recorded on this lead's "proposalId" custom field, if any. Looks up the proposal and its quotes from the database each call. Null if there is no proposal id set, the proposal cannot be found, it does not belong to this lead, or none of its quotes have been accepted.
getCalendarEvents()
Returns: List<CalEvent>
The events on the lead's linked profile's own calendar, looked up from the database each call. Empty if the lead has no linked profile.
getFunnelEdms()
Returns: List<FunnelEdm>
The funnel EDM (email direct marketing) sends recorded against this lead, looked up from the database each call.
leadFile(String att)
Returns: LeadFile
The file attached to this lead with the given name. A shorter alias for getFile, provided so templates can read a named attachment directly. Null if none matches.
| Parameter | Description |
|---|---|
att | the file name to match |
leadFile(Long id)
Returns: LeadFile
The file attached to this lead with the given database id. A shorter alias for getFile. Null if none matches.
| Parameter | Description |
|---|---|
id | the id of the lead file to find |
getFormattedTitle()
Returns: String
A display title for the lead: its description if set, otherwise its funnel's title, falling back to the funnel's name. Null if none of those are available.
addProduct(Product p)
Returns: LeadProduct
Adds a product to this lead with no quantity set, saving the new line item immediately.
| Parameter | Description |
|---|---|
p | the product to add |
addProduct(Product p, BigDecimal quantity)
Returns: LeadProduct
Adds a product to this lead at the given quantity, saving the new line item immediately. Does not check whether the product is already on the lead, so calling it twice creates two line items.
| Parameter | Description |
|---|---|
p | the product to add |
quantity | the quantity to record, or null for none |
removeProduct(Product p)
Returns: void
Deletes every line item on this lead that refers to the given product, so all duplicates are removed. Does nothing if the product is not on the lead.
| Parameter | Description |
|---|---|
p | the product to remove from the lead |
removeLeadProduct(Long id, Organisation org)
Returns: void
Deletes a single product line item by its id. The organisation scopes the lookup, so an id belonging to another organisation is not found.
| Parameter | Description |
|---|---|
id | the id of the line item to delete |
org | the organisation the line item belongs to |
removeAllProducts()
Returns: void
Deletes every product line item on this lead.
getLeadProducts()
Returns: List<Product>
The products associated with this lead, looked up from the database each call. Empty if no products have been added.
getLeadProductsList()
Returns: List<LeadProduct>
The LeadProduct join rows for this lead, each carrying a product and its quantity, looked up from the database each call. Empty if no products have been added.
getTitle()
Returns: String
The lead's title, a short free-text label. May be null.
getFormattedName()
Returns: String
A display name for the lead, equivalent to formattedName truncated to 35 characters.
formattedName(int maxLength)
Returns: String
A display name for the lead: its title if set, otherwise its description truncated to maxLength with an ellipsis appended, otherwise the customer profile's formatted name, otherwise the text Lead followed by the last four digits of the lead's id. Never null.
| Parameter | Description |
|---|---|
maxLength | the number of characters of the description to keep when the description is used |
hoursWorked()
Returns: double
The total hours recorded against this lead across all timesheet entries, with no date restriction. Sums the entries in the database on each call.
is(String type)
Returns: boolean
Type check used where a template or script handles several kinds of record through one variable. Returns true only for the type name lead, ignoring case.
| Parameter | Description |
|---|---|
type | the type name to test |
isStatus(LeadStatusType type)
Returns: boolean
Whether the lead is currently in the given status. ACTIVE means the lead has no closed date, CANCELLED means the cancelled flag is set, and COMPLETED means the lead is closed and not cancelled. Note that a cancelled lead which has not been closed matches both CANCELLED and ACTIVE. A null status returns false.
| Parameter | Description |
|---|---|
type | the status to test for |
getTransitions()
Returns: List<LeadJourneyTransition>
The recorded journey transitions for this lead, ie the history of goal/stage changes it has been through, looked up from the database each call.
getLeadTeams()
Returns: List<Organisation>
The organisations relevant to this lead: its assigned org if set, plus its customer organisation, falling back to the admin domain if there is no customer organisation.
getSummary()
Returns: String
A short human-readable summary of the lead, combining its lead number, title, deal amount, and cancelled/closed status into a single semicolon-separated string. Fields that are not set are omitted, so the result may be empty.