Lead and Customer are key entities for customer management. In this blog post we would suggest a solution for your online database that allows to convert Leads into Customers, such as Company accounts.
With help of a custom button, a user will be able to copy qualified Lead records into a separate “Companies” table. As a result, each converted lead will be saved as a new ‘company account’. In simple words, every Company record will be created as a copy of a converted Lead record. Moreover, a contact person stored in the Lead record, along with all the tasks related to the lead, should also be copied among all other related details of a newly created Company account.
For example, there are Leads, Companies, Persons and Tasks tables in your online database. When you add a new Lead, you should fill in the Company field and the Person field.
When a Lead is saved, you may add related Tasks underneath the Lead form:
To convert Lead into account, a user can click on the “Convert Lead” button. As a result, a new Company record corresponding to the initial Lead will be added to the “Companies” table automatically. Detail records, such as “Person” will be created as a related detail as well. Moreover, all existing incomplete Task records will also stay related to the Company account.
Please note that ParentKey() function, RecordSet column and Record Update actions are the most essential elements of the button configuration. All these elements help to simplify and automate button functionality.
Now let’s plan all the steps in details:
1. Create Reference columns in the “Leads” table
First, make sure that “Leads” table contains two reference columns: Converted Company and Converted Person.
It means that there is a One-to-Many relation between the “Leads” and the “Companies” table and there is also a similar relation between “Leads” and “Persons”.
These two reference columns are needed for keeping key values of a newly generated Company account and a Person profile in the master Lead record. These columns will be used in the “Convert Lead” button filters, in the update actions and assignments described below.
2. Create Reference columns in the “Companies” table
You should also add the following two single-reference columns to the “Companies” table: “Main Person” and “Lead”.
Both columns participate in the assignments of the actions triggered by the “Convert Lead” custom button.
3. Add Reference columns to “Tasks” tableWhen both – a new Company account and a Person profile are generated, all incomplete Tasks (where the Complete is not Checked) should be related to these Company record and a Person record via single-reference columns.
Reference column values will be assigned with help of the Update Record action described below. As a result, a user will be able to see all the incomplete Tasks related to a Company account and a Person profile as ‘related details’ underneath the form.
4. RecordSet column
“Tasks” and “Leads” tables are related via a single-reference column. As a result, you can see a list of Tasks as ‘related details’ underneath a Lead form. You can also create a RecordSet column in the Leads table.
This column acts as a reference to related Task records. In our example, there is an “Active Tasks” RecordSet column keeping the list of Task record initial Id’s taken from the related details. In addition, this column has a filter: ‘Complete is not Checked’, so only incomplete Tasks are selected.
This RecordSet column will be used in the Update Record action for updating the “Company” and the “Person” reference column values of all incomplete Tasks related to the Lead.
5.“Convert Lead” custom button
6. Add Actions to the button
The first “Create Company” action should create a new record in the “Companies” table. This Company record should be related to the initial Lead record. The resulting action includes the following assignments:
The second action “Create Person” should be configured in a similar way, except for adding the assignment with ParentKey() pseudo-function. This function takes the record key created by preceding workflow actions. Within the assignment, this key is inserted into the Company reference column, therefore the function takes a record key of the last record created by workflow action in the Companies table. In this example the above-mentioned “Create Company” action generates a new Company record, so, its key column value will be taken via ParentKey() function added to the assignment.
Record Update actions configuration is more complex. These actions also contain ParentKey() pseudo-function in the assignments. As mentioned above, this function picks up a key of a newly created ‘Company’ or a ‘Person’ records that were created by actions configured in the “Leads” table. The system tracks record keys that were generated by preceding workflow actions, one key per table. This enables us to assign a key of a newly created Company or a newly created Person record depending on the reference column specified in the assignments.
See three Record Update actions with assignments on the screenshots below.
“Save Company & Person to Lead” action
The purpose of this action is relating both newly created records (Company and Person) to the initial Lead via “Converted Company” and “Converted Person” reference columns.
This action updates the Lead record where “Convert Lead” button was clicked. According to the assignments, key values of the last record that were created via actions in the “Companies” and “Persons” tables are inserted into the “Converted Company” and “Converted Person” reference columns respectively.
“Set Main Person to Company” action
According to this action the newly created Person profile should be related to the new Company account via the “Main Person” single-reference column. That’s why the Record Update action should be configured the following way:
“Converted Company” column has to be selected in the “Record(s) to update” field. It indicates that the action should update the Company record with the key value which is kept in the “Converted Company” reference column of the Lead record, where the custom button was clicked.
Then the assignment inserts the Person record key via ParentKey() function into the “Main Person” reference column referring to the “Persons” table. The specific of the ParentKey() function is described in the actions listed above.
“Transfer Active Tasks” action
Now we need to relate incomplete Tasks to the newly created ‘Company’ and ‘Person’ records. We will use “Company” and “Person” reference columns within the assignments of this Update Record action.
Pay your attention to the action options. In the “Record(s) to update” field the “Active Tasks” RecordSet column is selected. It means that only Tasks, which key values are listed in the “Active Tasks” field, should be updated when a particular lead record’s “Convert Lead” button is clicked by a user.
As a result, with the help of the ParentKey() function the Company and the Person reference columns will be filled in by the key values of the last Company and the last Person record created via actions within correspondent tables.
At the end, we add “Navigate To Company” action. This is an action of the Navigate type. It readdresses a user to a view form of the newly created Company record after “Convert Lead” button is pressed.
The set of actions is now complete. You may review “Converting Lead” functionality in the Leads & Account preconfigured template.