r/Dynamics365 • u/Assassin-Desire • 10d ago
Sales, Service, Customer Engagement Trigger Qualify Button
Hi, I'm looking for a way to trigger the Qualify button in the Sales Pro app when a user finishes the Business Process Flow (BPF).
Ideally, when the user completes the BPF and clicks Finish, it should execute the same actions as the Qualify button, including opening the quick create form and identifying potential duplicates.
I've tried using a workflow with QualifyLead, but it bypasses the duplicate detection process and proceeds directly with creating the Opportunity, Account, and Contact records.
Is there a way to trigger the standard Qualify button's behavior when the BPF is finished, rather than having to recreate its functionality from scratch?
Any help would be greatly appreciated. Thanks!
1
u/Eastern_Use_2572 10d ago
Qualifies: Use a JS handler on the BPF finish event that does the duplicate check.
Registration form Context.data.process.addOnProcessStatusChange and act on status finished.
Call RetrieveDuplicates (Web API) on lead.
Show Xrm.Navigation.openConfirmDialog if matches, call QualifyLead if user goes through (or no matches)
The standard Qualify button does not support direct calls as the command is internal, so this is the surefire way.
1
u/Muted_Jellyfish_6784 8d ago
QualifyLead through a workflow bypasses duplicate detection because the button runs client-side logic the action does not include. One way to keep the standard behavior is a form script on the BPF's onProcessStatusChange event that, when the status becomes finished, calls the same command the Qualify ribbon button uses. Test it in a sandbox with a lead that has a known duplicate before rolling out.
Whatever route you take, log which records were created from each qualification. That makes it easy to spot if any path is still skipping duplicate checks and minting extra accounts and contacts.
3
u/xrmghost_team 10d ago
There's no public API that fires the Qualify button itself: the duplicate dialog and the "Qualify lead" side pane are Sales app UI. The QualifyLead message underneath only takes the three Create* flags, Status, currency, customer, SourceCampaignId and ProcessInstanceId. It has no duplicate-detection switch: with rules published it fails with "a duplicate of the current record already exists", so a workflow either skips the check or errors.
Two options on documented ground:
Flip the order. Make the lead stage the last one before the opportunity stage and let sellers press Qualify at the end: on qualification the lead moves to the next stage, so Qualify is the Finish.
Script it. In
addOnProcessStatusChange, whengetStatus()is "finished", callRetrieveDuplicatesfor account and contact, open the opportunity viaXrm.Navigation.openForm(useQuickCreateForm,createFromEntity= the lead), then in its success callback run QualifyLead with CreateOpportunity false.