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

PropertyReturnsDescription
acceptedQuoteQuoteThe 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.
adminDomainOrganisationThe organisation that owns this lead, ie the tenant running the funnel. Never null.
allFieldValuesMap<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.
allParticipantsList<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.
assetIdStringFor a lead that relates to a specific asset, the uniqueId of that asset. Null for leads not associated with an asset.
assignedToGroupGroupThe group currently assigned to handle this lead, if any.
assignedToOrgOrganisationThe sub-organisation assigned to handle this lead, if any.
assignedToProfileProfileThe team member assigned to handle this lead, if any. Also referred to as the lead's owner.
calendarEventsList<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.
cancelledbooleanWhether this lead has been cancelled, ie lost rather than won.
cancelledReasonStringA code indicating the general reason this lead was lost. Null unless the lead is cancelled.
ccListStringA comma-separated list of additional recipients to include on communications about this lead, up to 20000 characters. May be null.
closedDateDateThe date this lead was finished, whether won or lost. Null while the lead is still active.
companyStringThe company name captured for this lead when it cannot yet be linked to a full Organisation. May be null.
completedProcessingAtDateWhen timer processing for the current goal was successfully completed. Null while processing is still pending or in progress.
createDateDateWhen this lead was created. Never null once persisted.
createdByProfileThe user who created this lead, if it was created by a team member rather than automatically from an inbound enquiry. May be null.
currentGoalStringThe name of the goal the lead is currently trying to attain. Once attained, processing moves on to the next goal in the funnel.
dealAmountBigDecimalThe expected sale value of this deal. May be null if not yet estimated.
deletedByProfileThe user who deleted this lead, if it has been soft-deleted.
deletedDateDateWhen this lead was soft-deleted. Null for a lead that has not been deleted.
descriptionStringA free-text description of this lead, up to 20000 characters. May be null.
emailStringThe 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.
engagementScoreDoubleA 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.
estimatedHoursDoubleThe estimated hours of work required for this lead. May be null if not estimated.
fieldsNvSetThe 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.
filesList<LeadFile>The files attached to this lead. May be null or empty if none have been attached.
firstNameStringThe 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.
formattedNameStringA display name for the lead, equivalent to formattedName truncated to 35 characters.
formattedTitleStringA 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.
funnelFunnelRepositoryThe funnel this lead is progressing through. Never null for a lead created via Lead.create.
funnelBranchStringThe name of the funnel branch/version this lead is connected to, fixing the process definition it follows even if the funnel is later edited.
funnelEdmsList<FunnelEdm>The funnel EDM (email direct marketing) sends recorded against this lead, looked up from the database each call.
idlongThe database identifier for this lead. Assigned on first save and never changes.
initialContactDateDateWhen the contact first requested information, used as the baseline for measuring response time. May be null if not recorded.
jobTitleStringThe job title captured for this lead's contact. May be null.
lastAttainedDateDateThe date and time the most recent goal was attained. May be null if the lead has not yet attained a goal.
lastAttainedGoalStringThe name of the most recently attained goal. May be null if no goal has been attained yet.
lastContactRequestContactRequestThe 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.
leadNumStringA user-controlled identifier for the lead, intended to be unique within the owning organisation. Nullable, up to LEAD_NUM_MAX_LENGTH characters.
leadProductsList<Product>The products associated with this lead, looked up from the database each call. Empty if no products have been added.
leadProductsListList<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.
leadTeamsList<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.
modifiedDateDateWhen this lead was last modified.
mostRecentTaskTaskThe most recently created task linked to this lead, looked up from the database each call. Null if the lead has no tasks.
numAttemptsIntegerThe number of times timer processing has been attempted for this lead's current goal. Null before the first attempt.
participantsList<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.
phoneStringThe 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.
processingStartedAtDateWhen 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.
profileProfileThe 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.
profileScoreDoubleA 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.
scoreDateDateWhen getEngagementScore and getProfileScore were last calculated. Null if scores have not yet been calculated.
sourceStringWhere this lead originated from, for example facebook or googleAd. May be null if the source was not recorded.
sourceLeadLeadThe lead this one was derived or cloned from, if any.
stageNameStringThe 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.
statusStringA simple status label for the lead: Active while still in progress, Won once closed successfully, or Lost if cancelled.
summaryStringA 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.
surNameStringThe surname captured for this lead when it cannot yet be linked to a full customer Profile. Null once the lead has a linked profile.
timerDateDateThe 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.
titleStringThe lead's title, a short free-text label. May be null.
trackingIdStringThe 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.
transitionsList<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.

ParameterDescription
roleKeythe role to look up

getParticipants(String roleKey)

Returns: List<LeadParticipant>

All participants filling the given role - use for multi-valued custom roles.

ParameterDescription
roleKeythe 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.

ParameterDescription
nowthe 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.

ParameterDescription
namethe 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.

ParameterDescription
idthe 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.

ParameterDescription
namethe 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.

ParameterDescription
namethe name of the custom field to write, or dealAmount or title for the lead's own columns
valuethe 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.

ParameterDescription
attthe 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.

ParameterDescription
idthe 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.

ParameterDescription
pthe 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.

ParameterDescription
pthe product to add
quantitythe 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.

ParameterDescription
pthe 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.

ParameterDescription
idthe id of the line item to delete
orgthe 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.

ParameterDescription
maxLengththe 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.

ParameterDescription
typethe 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.

ParameterDescription
typethe 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.

To get full access to the Kademi Hub existing customers can login here, or new customers can register here.