web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Plugin Code to Query Entity Records

(0) ShareShare
ReportReport
Posted on by 5

Hi

I am novice when it comes to plugins and looking for some help/code to do the following;

When a new contact record is created, I want to query the email address on the contact record against the records held in the lead entity, and if there is a match, linked the lead record to the contact record via the lookup field.

I have been searching for some code, I could tweak but been relatively unsuccessful.

Any help/pointers would be greatly apprieciated.

Thanks

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    It's always easier to start from something. Share what you have.

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    You can achieve your requirement with fetchXml.

    Please see below blog for more details

    carldesouza.com/.../

  • Shaun W Harvey Profile Picture
    242 on at

    Hi,

    Andrew is correct. Let us see what you have. We can help from there.

    Although, It sounds like you will need a Pre-Operation plugin on Create Of Contact.

    You will be able to read the e-mail address from the "Target" object which represents the contact that will be created.

    You can then use either FetchXML or QueryExpression to form a query to search for a Lead with that e-mail address.

    You'll then be able to populate the "Originating Lead" lookup on the "Target".

    So, it'll apply to the DB as single commit.

    Best Regards,

    Shaun Harvey

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans