Skip to content

Implemented QualifyLeadRequestHandler#51

Closed
Ladekarl wants to merge 6 commits into
masterfrom
30_ImplementQualifyLeadRequest
Closed

Implemented QualifyLeadRequestHandler#51
Ladekarl wants to merge 6 commits into
masterfrom
30_ImplementQualifyLeadRequest

Conversation

@Ladekarl

Copy link
Copy Markdown
Contributor

#30

@Ladekarl
Ladekarl requested a review from magesoe April 16, 2018 13:03

@TomMalow TomMalow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test are missing asserts that verifies that data have been created in the mockup database.

The Qualify lead process does not currently create any Opportunities and are missing some checks such as it should not be possible to add an existing account to the qualifying process with out requiring creation of a new Opportunity.

Qualify lead does not handle any kind of duplicate detection when creating new account or contacts.

}

var resp = new QualifyLeadResponse();
resp.Results["CreatedEntities"] = createdEntities;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to create the entities in the mockup database. Currently you just respond with almost the same data as the user has requested. Additionally, you also need to update the state of the Lead to Qualified.

}

[TestMethod]
public void TestQualifyLeadRequestCreateAccountSuccess()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing assert that lead has been qualified and that a new account has been created

}

[TestMethod]
public void TestQualifyLeadRequestOpportunityCustomerIdSuccess()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing assert that lead has been qualified. This test should also fails as you need to also set CreateOpportunity if you want to set OpportunityCustomerId as it defines an existing account that the opportunity should point to

}

[TestMethod]
public void TestQualifyLeadRequestCreateContactSuccess()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing assert that lead has been qualified and check if a new contact have been created

}

[TestMethod]
public void TestQualifyLeadRequestSuccess()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing assert if the lead has been qualified

}

[TestMethod]
public void TestQualifyLeadRequestCreateAllSuccess()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing assert that lead has been qualified and that a new Opportunity and Account have been created and that the opportunity points the the new account and existing contact


if (request.CreateContact)
{
var contactAlreadyExists = db["contact"].Any(row => row["fullname"] != null && row["fullname"].Equals(lead["fullname"]));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think Qualified Lead handles any kind of duplicate detection in CRM.


if (request.CreateAccount)
{
var accountAlreadyExists = db["account"].Any(row => row["name"] != null && row["name"].Equals(lead["fullname"]));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think Qualified Lead handles any kind of duplicate detection in CRM.

throw new FaultException("A record was not created or updated because a duplicate of the current record already exists.");
}

var account = new Entity

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qualify lead uses some of the fields on the lead when creating the account. Such as the Company text field

throw new FaultException("A record was not created or updated because a duplicate of the current record already exists.");
}

var contact = new Entity

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qualify Lead uses fields on the lead when creating the contact such as Contact Name and Job title.

@magesoe magesoe added the review label Aug 2, 2018
@ghost ghost assigned Ladekarl Aug 13, 2018
mkholt added a commit that referenced this pull request Jul 8, 2026
Implements QualifyLeadRequestHandler for the QualifyLead message: optionally
creates account/contact/opportunity from the lead (copying the standard mapped
fields), links the opportunity via originatingleadid, and closes the lead in the
status/state supplied on the request. Attributes not present on the target
entity's metadata are skipped with a warning rather than failing the request
(Core now exposes its ILogger so handlers can surface such diagnostics).

Lead metadata is absent from the leaned test environment, so it is supplied as a
standalone LeadMetadata.xml (custom-publisher fields stripped), merged like the
existing RemovedEntitiesMetadata.xml. Adds TestLeads covering creation, mapping,
qualify/disqualify, and the validation/guard paths.

Re-implements and builds on the original work by Niels Ladekarl (@Ladekarl) in
#51, updated for the current codebase and test environment.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>
mkholt added a commit that referenced this pull request Jul 9, 2026
* Add QualifyLead request handler

Implements QualifyLeadRequestHandler for the QualifyLead message: optionally
creates account/contact/opportunity from the lead (copying the standard mapped
fields), links the opportunity via originatingleadid, and closes the lead in the
status/state supplied on the request. Attributes not present on the target
entity's metadata are skipped with a warning rather than failing the request
(Core now exposes its ILogger so handlers can surface such diagnostics).

Lead metadata is absent from the leaned test environment, so it is supplied as a
standalone LeadMetadata.xml (custom-publisher fields stripped), merged like the
existing RemovedEntitiesMetadata.xml. Adds TestLeads covering creation, mapping,
qualify/disqualify, and the validation/guard paths.

Re-implements and builds on the original work by Niels Ladekarl (@Ladekarl) in
#51, updated for the current codebase and test environment.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>

* Address Copilot review on QualifyLead

- Validate OpportunityCurrencyId references a transactioncurrency, throwing a
  clear FaultException early. (A non-existent currency already surfaced as a
  FaultException from the create pipeline via XrmDb.GetDbRow, not an NRE; added
  TestQualifyLeadNonexistentCurrencyThrowsFault to lock that in.)
- Test capture logger's BeginScope now returns a NullScope singleton instead of
  null, matching the precedent in TestLogging.cs.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>

---------

Co-authored-by: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>
@mkholt

mkholt commented Jul 9, 2026

Copy link
Copy Markdown
Member

Implemented and released in #343

@mkholt mkholt closed this Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants