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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Prevent duplicate connections for Contacts on custom entity

(0) ShareShare
ReportReport
Posted on by

Hi,

How can I avoid creating duplicate connections when custom entity has two lookup fields referring to two contacts lookup?

Just want to avoid creating another connection on save if connection between these two contacts already exists? Something with respect to java script is appreciated rather than plugin or workflow.

Thanks

Nikhil

I have the same question (0)
  • Bipin D365 Profile Picture
    28,985 Moderator on at

    Hi,

    You can easily achieve this with Fetchxml.

    CR11.PNG

    And you would need to execute this fetchxml code frm JS to check if count is zero then no connection exist.

    CR12.PNG

    You will have to replace Contact Record GUID dynamically based on your lookup values.

    Hope this helps!

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Nya Profile Picture
    29,064 on at

    Hi Nikhil,

    As the JavaScript has limitations and only works on Form, it is recommended to use the Duplicate Detection, which is an OOTB feature.

    1. Enable the Duplicate detection for the connection entity first.

    pastedimage1639387032939v1.png

    2. Navigate to Advanced Settings > System > Data Management.

    pastedimage1639387116993v3.png

    3. Create a duplication detection rule for connection entity and publish it.

    pastedimage1639387247969v4.png

    4. Then when a duplicate connection is created, there will be a prompt dialog for duplicate records.

    pastedimage1639387469302v5.png

  • Community Member Profile Picture
    on at

    Thanks Nya, however it was not this I was looking for. I am very well aware of Duplicate Detection rules.

    My requirement is more or less what Bipin is coming up with.

    1) Let's say - I've X Entity with two lookups to Contact entity.

    2) I've connection already present on those contacts lookup value selected.

    3) Requirement is from X Entity if I go and select again those two contacts from lookups then find out if connection exists and if 'Yes' - hide field of 'create connection' flag or else Show the flag field.

    Thanks all but waiting...

    Nikhil

  • Community Member Profile Picture
    on at

    Hi,

    Managed to achieve object through fetchxml and webapi. Thanks all for your replies and help.

    Nikhil

  • Suggested answer
    Nya Profile Picture
    29,064 on at

    Hi Nikhil,

    Great to hear that.

    Thanks for your sharing!

    This thread will be closed.

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

    Hi,

    Glad that it worked using Fetchxml and webapi.

    Please mark this thread verified so that it will be helpful for other community member.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 156

#2
ManoVerse Profile Picture

ManoVerse 52 Super User 2026 Season 1

#3
Niki Patel Profile Picture

Niki Patel 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans