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,...
Answered

Create a N:N record via JavaScript and Web API

(0) ShareShare
ReportReport
Posted on by 154

Basically, I have an entity that stores N:N relationships between two other entities. A record looks like the following:

{
    "@odata.context": "https://company.crm.dynamics.com/api/data/v9.0/$metadata#po_po_mailchimpcampaign_listset",
    "value": [
        {
            "listid": "264c9b4e-82fe-ea11-a815-000d3a5bbb60",
            "po_po_mailchimpcampaign_listid": "ba311a10-64ff-ea11-a815-00224806a2ff",
            "versionnumber": 81274591,
            "po_mailchimpcampaignid": "8e9b89bb-63ff-ea11-a815-00224806a2ff"
        }
    ]
}

The "listid" is one of the records, the "po_mailchimpcampaignid" is the other. These GUIDs are simple enough to get. The "po_po_mailchimpcampaign_listid" is the GUID for the relationship record.

Starting out small, I'm just trying to create a new record in this entity by doing a simple POST to the web API in that entity from Postman. This is what I get back though:

Screen-Shot-2020_2D00_09_2D00_25-at-1.30.46-PM.png

So apparently, you can't do a simple Create in this in entity, which has me stumped as to how I'm supposed to implement a JavaScript solution if I can't even use the Web API to Create a new record in it.

Suggestions for how to handle this?

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

    Hello,

    That's because to associate records you should use "Associate" message and following post shows how you can do it - himbap.com/.../

  • Suggested answer
    cloflyMao Profile Picture
    25,210 on at

    Hi Jones,

    It seems that the entity(po_po_mailchimpcampaign_listid) is a native intersect entity created by system to store N:N relationships.

    If so, the native intersect entity is not supported to be created directly, we need to to use association operation:

    https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/associate-disassociate-entities-using-web-api#add-a-reference-to-a-collection-valued-navigation-property

    Url: [OrganizationUrl]/api/data/v9.1/lists(aaaa)/relationshipname/$ref

    Body:

    {
          "@odata.id": "https://company.crm.dynamics.com/api/data/v9.1/po_mailchimpcampaigns(bbbb)"
    }

    pastedimage1601260891226v1.png

    Another option is that you could create a manual intersect entity to manage N:N relationship between two entities.

    https://carldesouza.com/understanding-intersect-entities-and-nn-relationships-in-dynamics-365/

    Regards,

    Clofly

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