Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum

Retrieve contactid from the originatingleadid of an Opportunity in Dynamics 365 v9.x

Posted on by 15

When a Lead is qualified it will always create a new Opportunity record and will also create a new Account and Contact record as well unless you identify the Lead as belonging to an existing Account and/or existing Contact.  In our use case, which I don't think is unique, we track both the Account and Contact associated with an Opportunity.  In our use case we set a specific Account for new Leads and set the customerid field on the Lead form using Javascript.

When we qualify the Lead a new Opportunity is created and the customerid field is inherited from the Lead and a reference to the Lead is populated in the originatingleadid field.  A new Contact is also created with information from the Lead and a reference to the same Lead is populated in the originatingleadid field.

Now, I would like to populate the newly created Opportunity with a reference to the newly created Contact in a custom field say new_contactid.  The only way I can get to the newly created contactid (Contact) is from the originatingleadid field.

Can I get the contactid value from a Contact record querying on the originatingleadid field using Javascript or some other method?

Any help appreciated.  Thanks!

  • Suggested answer
    LuHao Profile Picture
    LuHao 40,872 on at
    RE: Retrieve contactid from the originatingleadid of an Opportunity in Dynamics 365 v9.x

    Hi MrMarkS,

    You could do this using a workflow.

    Create a new workflow for the entity with Opportunity.

    Add step "Update Record".

    2744.2.JPG

    Click "Set Properties" button. Select "Contact (Contact)" and "Originating Lead" in the Look for column, then add it to the contactid field.

    2744.2.JPG

    Save and Activate it.

    When you qualify a lead, the newly created Opportunity will automatically populate the contactid field. You have to refresh the Opportunity page to see the effect.

    ---------------------------------

    In addition, your needs seem to be OOB feature, that is the new Opportunity contact is the name of the qualify lead.

    So you could replace your custom field new_contactid with the Opportunity contact.

    If I misunderstand your needs, please correct me.

    Maybe because the contact field can be modified manually, so you want a custom field that cannot be modified. Then the workflow I provide can meet your needs.

    Hope this helps.

    Best Regards,

    Lu Hao

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

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