Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Unanswered

Retrieve the Opportunity created by qualifying lead (QualifyLead)

Posted on by 275

Hi Guys

I'm trying to update some fields on Account, Contact and Opportunity that are created by qualifying a lead. Using below code to achieve it but the only record that is being retrieved is account. Contact and Opportunity are not being retrieved. 

EntityReference entity = (EntityReference)context.InputParameters["LeadId"];
Entity lead = service.Retrieve("lead", entity.Id, new ColumnSet(true));


foreach (EntityReference created in (IEnumerable)context.OutputParameters["CreatedEntities"])
{
if (created.LogicalName == "account")
{
Entity account = service.Retrieve("account", created.Id, new ColumnSet(true));
} 
if (created.LogicalName == "contact")
{
Entity contact = service.Retrieve("contact", created.Id, new ColumnSet(true));
}
if (created.LogicalName == "opportunity")
{
Entity opportunity = service.Retrieve("opportunity", created.Id, new ColumnSet(true));

}

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Retrieve the Opportunity created by qualifying lead (QualifyLead)

    I agree, we shouldn't need to use a workaround for the functionality which should be available out of box. It could be a bug also. You could raise a support case with Microsoft to confirm this behavior.

  • Turbo Forms Profile Picture
    Turbo Forms 275 on at
    RE: Retrieve the Opportunity created by qualifying lead (QualifyLead)

    Hi Ravi, yes all the 3 records are being created. But when debugged only the first if conditions for account is returning true while remaining two if conditions are returning false.

    I had to use retrieve parentaccountid and parentcontactid fields on lead post async of QualifyLead and then use account information to retrieve latest opportunity. My approach works but not satisfied as I didnt have to do this work around where a straight approach would save few lines of code.

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Retrieve the Opportunity created by qualifying lead (QualifyLead)

    Hi,

    Did you check if the contact and opportunities are being created when you qualify lead? The code looks correct.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans