Implemented QualifyLeadRequestHandler#51
Conversation
TomMalow
left a comment
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
Missing assert that lead has been qualified and that a new account has been created
| } | ||
|
|
||
| [TestMethod] | ||
| public void TestQualifyLeadRequestOpportunityCustomerIdSuccess() |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
Missing assert that lead has been qualified and check if a new contact have been created
| } | ||
|
|
||
| [TestMethod] | ||
| public void TestQualifyLeadRequestSuccess() |
There was a problem hiding this comment.
Missing assert if the lead has been qualified
| } | ||
|
|
||
| [TestMethod] | ||
| public void TestQualifyLeadRequestCreateAllSuccess() |
There was a problem hiding this comment.
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"])); |
There was a problem hiding this comment.
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"])); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Qualify Lead uses fields on the lead when creating the contact such as Contact Name and Job title.
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>
* 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>
|
Implemented and released in #343 |
#30