docs/docs/en/tutorials/v1/18-lead-followup.md
In this chapter, we will learn how to implement CRM lead conversion in NocoBase. Through lead follow-up and status management, you can boost operational efficiency and achieve more refined sales process control.
In the previous chapter, we explained how to associate data between leads and the Company, Contact, and Opportunity collections. Now, we focus on the Lead module, primarily discussing how to perform lead follow-up and status management. Please watch the following demo:
In the lead follow-up functionality, the "status" field plays a crucial role. It not only reflects the current progress of the lead (e.g., Unqualified, New, Working, Nurturing, In Transaction, Completed) but also drives the dynamic display and changes of the form. The following table block shows the field structure of the Lead collection along with its detailed description:
| Field name | Display Name | Field Interface | Description |
|---|---|---|---|
| id | Id | Integer | Primary key |
| account_id | account_id | Integer | Foreign key of the ACCOUNT collection |
| contact_id | contact_id | Integer | Foreign key of the CONTACT collection |
| opportunity_id | opportunity_id | Integer | Foreign key of the OPPORTUNITY collection |
| name | Lead Name | Single line text | Name of the prospective customer |
| company | Company Name | Single line text | Name of the prospective customer's company |
| Email address of the prospective customer | |||
| phone | Contact Number | Phone | Contact number |
| status | Status | Single select | Current lead status (Unqualified, New, Working, Nurturing, In Transaction, Completed) |
| Account | Company | Many to one | Linked to the Company collection |
| Contact | Contact | Many to one | Linked to the Contact collection |
| Opportunity | Opportunity | Many to one | Linked to the Opportunity collection |
First, we need to create a "Leads" table block to display the necessary fields. At the same time, configure a detail block on the right side of the page so that when you click on a record, the corresponding details are automatically displayed. Please refer to the demo below:
To meet various operational needs, we need to create a total of 11 buttons. Each button will display differently (hidden, active, or disabled) based on the record's status, guiding the user through the correct business process.
In the page, we use Handlebars syntax to dynamically display different prompt messages based on the record's status. Below are example codes for each status:
When the status is "Unqualified":
{{#if (eq $nRecord.status "Unqualified")}}
**Track the details of your unqualified leads.**
If your lead is not interested in the product or has left the related company, it might be unqualified.
- Record lessons learned for future reference
- Save outreach details and contact information
{{/if}}
When the status is "New":
{{#if (eq $nRecord.status "New")}}
**Identify the products or services required for this opportunity.**
- Gather customer cases, reference materials, or competitor analyses
- Confirm your key stakeholders
- Determine available resources
{{/if}}
When the status is "Working":
{{#if (eq $nRecord.status "Working")}}
**Deliver your solution to stakeholders.**
- Communicate the value of your solution
- Clarify timelines and budgets
- Develop a plan with the customer on when and how to close the deal
{{/if}}
When the status is "Nurturing":
{{#if (eq $nRecord.status "Nurturing")}}
**Determine the customer's project implementation plan.**
- Reach agreements as needed
- Follow the internal discount process
- Obtain a signed contract
{{/if}}
When the status is "Completed":
{{#if (eq $nRecord.status "Completed")}}
**Confirm the project implementation plan and final steps.**
- Ensure all remaining agreements and sign-off procedures are in place
- Adhere to the internal discount policy
- Ensure the contract is signed and the project proceeds as planned
{{/if}}
After conversion, we want to display the associated objects (Company, Contact, Opportunity) along with links to their detail pages. Note: In other pop-ups or pages, the last part of the detail link (after filterbytk) represents the current object's id. For example:
http://localhost:13000/apps/tsting/admin/w3yyu23uro0/popups/ki0wcnfruj6/filterbytk/1
For Company:
{{#if (eq $nRecord.status "Completed")}}
**Account:**
[{{$nRecord.account.name}}](http://localhost:13000/apps/tsting/admin/w3yyu23uro0/popups/ki0wcnfruj6/filterbytk/{{$nRecord.account_id}})
{{/if}}
For Contact:
{{#if (eq $nRecord.status "Completed")}}
**Contact:**
[{{$nRecord.contact.name}}](http://localhost:13000/apps/tsting/admin/1oqybfwrocb/popups/8bbsqy5bbpl/filterbytk/{{$nRecord.contact_id}})
{{/if}}
For Opportunity:
{{#if (eq $nRecord.status "Completed")}}
**Opportunity:**
[{{$nRecord.opportunity.name}}](http://localhost:13000/apps/tsting/admin/si0io9rt6q6/popups/yyx8uflsowr/filterbytk/{{$nRecord.opportunity_id}})
{{/if}}
To ensure that associated information is displayed properly after conversion, the statuses for "Company", "Contact", and "Opportunity" should be set to "hidden (retain value)". This way, even though these fields are not shown on the form, their values are still recorded and passed along.
To prevent accidental changes to the status after conversion, we add a condition to all buttons: when the status is "Completed", all buttons will be disabled.
After completing all of the above steps, your lead follow-up conversion functionality is complete! Through this step-by-step guide, we hope you have gained a clearer understanding of how status-based form dynamics and linkages are implemented in NocoBase. Wishing you smooth operations and an enjoyable experience!