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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

[JScript] Disassociate entities with N:N relationship

(0) ShareShare
ReportReport
Posted on by

Hi,

I'am trying to disassociate entities in Javascript with the following request :

    var request = "      <Request type='DisassociateRequest'>";
    request += "        <Parameters>";
    request += "          <KeyValuePairOfstringanyType>";
    request += "            <key>Moniker1</key>";
    request += "            <value type='EntityReference'>";
    request += "              <Id>" + firstEntityId + "</Id>";
    request += "              <LogicalName>" + firstEntityName + "</LogicalName>";
    request += "            </value>";
    request += "          </KeyValuePairOfstringanyType>";
    request += "          <KeyValuePairOfstringanyType>";
    request += "            <key>Moniker2</key>";
    request += "            <value type='EntityReference'>";
    request += "              <Id>" + secondEntityId + "</Id>";
    request += "              <LogicalName>" + secondEntityName + "</LogicalName>";
    request += "            </value>";
    request += "          </KeyValuePairOfstringanyType>";
    request += "          <KeyValuePairOfstringanyType>";
    request += "            <key>RelationshipName</key>";
    request += "            <value type='string'>" + relationshipName + "</value>";
    request += "          </KeyValuePairOfstringanyType>";
    request += "        </Parameters>";
    request += "        <RequestName>DisassociateRequest</RequestName>";
    request += "      </Request>";


But that doesn't work. in the error message returned, i have only : "request" (very helpful -_-')

Have you an idea of what is wrong in my request ? I precise that the request is sent by an utility that manage Crm and Soap requests. It's XrmServiceToolkit

.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mehdi Chemseddine Profile Picture
    110 on at
    RE: [JScript] Disassociate entities with N:N relationship

    Hi,

    You can use the Disassociate REST function in XrmServiceToolkit :

                XrmServiceToolkit.Rest.Disassociate(
                        contactId,
                        "ContactSet",
                        accountId,
                        "account_primary_contact",
                        function () {
                            equals(true, true, "The record should have been disassociated.");
                        },
                        function (error) {
                            equal(true, false, error.message);
                        },
                        false
                    );
  • Verified answer
    Community Member Profile Picture
    on at
    RE: [JScript] Disassociate entities with N:N relationship

    I've found the answer. I'am using sdk.soap.js instead of xrmservicetoolkit. Like this :

       var secondEntityGuid = Sdk.Guid(secondEntityName + 'id', secondEntityId);
    
       var firstEntityGuid = Sdk.Guid(firstEntityName + 'id', firstEntityId.replace('{','').replace('}',''));
    
       var account = new Sdk.EntityReference(secondEntityName, secondEntityGuid.getValue());
    
       var collection = new Sdk.Collection(Sdk.EntityReference, new Array(account));
    
       Sdk.Async.disassociate(firstEntityName, firstEntityGuid.getValue(), relationshipName, collection, sdkRequestSuccess, sdkRequestFailed, null);


  • Community Member Profile Picture
    on at
    RE: [JScript] Disassociate entities with N:N relationship

    I didn't seen you're answer. We doesn't use REST. I'ts not the best idea to stay on soap, but i'am not the manager of this project :)

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans