Create Custom Workflow Process in Dynamics CRM to Qualify LeadsBrandon Carnahan
In the latest Tales from the Trenches, Jesse shares his expereinces with custom workflows in Dynamics CRM 2016.
If you’ve dug around in the SDK, you may have found out by now that the Lead Qualification process can be adjusted to create only one or two out of Account, Contact, and Opportunity records, but only in custom code. The default system behavior in CRM when pressing the “Qualify” button is to create all three records, and you’ll find many discussions on workarounds online involving custom Actions, scripts and plugins. However, here are some easier tricks you may not have learned or may never become common knowledge.
1. Ribbon Workbench (or otherwise editing XML) can allow you to add a new button with new behavior
The interface for this tool may be daunting, but for those less interesting in manually editing Solution XML, this will allow you to add a new Ribbon Button onto the Lead entity, and hide the original OOB button. It installs as a Solution and has good documentation to get you started.
I also recommend installing ProcessJS. By including this as a Web Resource on the Lead Form, you can call a Workflow with only one line of code:
Afterward, you will be doing only the following:
- Finish building out the Workflow
2. Virtually all of the Qualification logic can be replicated in a Workflow
Let’s discuss what Qualification actually does when hitting the OOB button:
- Create records with Mapped attributes, both OOB and custom
- Set the Originating Lead for all new Records
- Make sure each Record is tied to the other (Account to Opportunity, Contact to Account, etc)
- Change the Status of the Lead
- Move the User from the Lead page to the newly created Opportunity (if applicable)
All of this can be done in an On-Demand Workflow, assuming you do the main operations in the correct Order:
- Create Account (if applicable)
- Create Contact (if applicable) and connect it to the Account
- Create Opportunity and connect the Contact and Account
- Set the Lead’s Qualifying Opportunity to the new Opportunity
- Do a Status Change on Lead to change it to Qualified
Note that you may need to have multiple branches to handle different conditions in the Workflow, but you’ll still want to follow the above order in each.
3. A Real-time Workflow that performs a Status change will also provoke navigation to the next page
This is the big undocumented “secret”. If you run a Real-Time workflow that forces a Status change on the Lead to Qualified while you are on the Lead Form, and the Opportunity has already been created and set to the Qualifying Opportunity, the system will automatically send the User’s browser to the created Opportunity! This appears to mimic “enough” of what CRM is expecting behind the scenes on the default Qualify button to trigger the same logic in motion.
(Note that all of this was tested only in CRM 2016)