locked
'create' method does not support entities of type 'new_conract_contact' RRS feed

  • Question

  • Hi.

    I make relationship between contact and contract.

    I use JavaScript for create SOAP request to CreateEntity service:

     

    <soap:Body><Create xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>

    <entity xsi:type='new_contract_contact'>

    <contractid>{628BFE61-7B8A-DF11-9E32-D8D3855D64BD}</contractid>

    <contactid>{ED76A71C-E47D-DF11-9E32-D8D3855D64BD}</contactid>

    </entity></Create></soap:Body></soap:Envelope>"

     

    Response:  'create' method does not support entities of type 'new_contract_contact'

    I need make relationship-link between contract and contact in JavaScript.

    Please help.

    Monday, July 12, 2010 9:50 AM

Answers

  • hmmm, you need to download this from below URL (Click on download option from left side)

    http://www.stunnware.com/crm2/topic.aspx?id=JSWebService

     


    Mahain
    Tuesday, July 13, 2010 4:41 AM
    Moderator
  • Hi,

    you can use below tool to convert you c# code into JS code

    http://www.stunnware.com/crm2/topic.aspx?id=JSWebService

     


    Mahain
    Monday, July 12, 2010 10:54 AM
    Moderator
  • var xml = "" + 
    "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + 
    "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + 
     GenerateAuthenticationHeader() + 
    " <soap:Body>" + 
    "  <Execute xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + 
    "   <Request xsi:type=\"AssociateEntitiesRequest\">" + 
    "    <Moniker1>" + 
    "     <Id xmlns=\"http://schemas.microsoft.com/crm/2006/CoreTypes\"> 628BFE61-7B8A-DF11-9E32-D8D3855D64BD</Id>" + 
    "     <Name xmlns=\"http://schemas.microsoft.com/crm/2006/CoreTypes\">contract</Name>" + 
    "    </Moniker1>" + 
    "    <Moniker2>" + 
    "     <Id xmlns=\"http://schemas.microsoft.com/crm/2006/CoreTypes\"> ED76A71C-E47D-DF11-9E32-D8D3855D64BD </Id>" + 
    "     <Name xmlns=\"http://schemas.microsoft.com/crm/2006/CoreTypes\">contact</Name>" + 
    "    </Moniker2>" + 
    "    <RelationshipName>new_contract_contact</RelationshipName>" + 
    "   </Request>" + 
    "  </Execute>" + 
    " </soap:Body>" + 
    "</soap:Envelope>" + 
    "";
    
    var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
    
    xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
    xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute");
    xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
    xmlHttpRequest.send(xml);
    
    var resultXml = xmlHttpRequest.responseXML;
    

    above is java script code for this ..Please check out following article which explains how to create M:M relationship in CRM.

    http://blogs.msdn.com/crm/archive/2008/02/14/crm-4-0-relationships-explained.aspx

     

    Hope this helps..

     

     

    Monday, July 12, 2010 2:17 PM
  • Ouuuh.   Sorry.  I raplace C# code to code of AssociateRequest, and tool return JS code + XML source.

    Thanks. Now all work.

    I cut firs symbol of contract GUID in my JavaScript code. Now all fixed.

     

    Thanks Mahender.

    Tuesday, July 13, 2010 5:39 AM

All replies

  • Hi,

    you can't use ms crmservice create method to create relationship, you have to use metadata service for that

    refer for the same

    http://msdn.microsoft.com/en-us/library/cc156290.aspx

    Also you can take help of below post to use metadata service in JS

    http://blog.customereffective.com/blog/2009/02/client-side-web-service-calls-for-microsoft-dynamics-crm-40-calling-the-metadata-service-with-javascript.html

     


    Mahain
    Monday, July 12, 2010 10:20 AM
    Moderator
  • Is the relationship that you created a many-to-many relationship ? If so, you need to use an AssociateEntities message to create the instance of the relationship, and not the Create message
    Microsoft CRM MVP - http://mscrmuk.blogspot.com  http://www.excitation.co.uk
    Monday, July 12, 2010 10:36 AM
    Moderator
  • Yes,  it many-to-many relship.

    I need XML code of AssociateEntities-request, or JS source. Please.

    I not have VB or C#.

    Monday, July 12, 2010 10:46 AM
  • Hi,

    you can use below tool to convert you c# code into JS code

    http://www.stunnware.com/crm2/topic.aspx?id=JSWebService

     


    Mahain
    Monday, July 12, 2010 10:54 AM
    Moderator
  • var xml = "" + 
    "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + 
    "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + 
     GenerateAuthenticationHeader() + 
    " <soap:Body>" + 
    "  <Execute xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + 
    "   <Request xsi:type=\"AssociateEntitiesRequest\">" + 
    "    <Moniker1>" + 
    "     <Id xmlns=\"http://schemas.microsoft.com/crm/2006/CoreTypes\"> 628BFE61-7B8A-DF11-9E32-D8D3855D64BD</Id>" + 
    "     <Name xmlns=\"http://schemas.microsoft.com/crm/2006/CoreTypes\">contract</Name>" + 
    "    </Moniker1>" + 
    "    <Moniker2>" + 
    "     <Id xmlns=\"http://schemas.microsoft.com/crm/2006/CoreTypes\"> ED76A71C-E47D-DF11-9E32-D8D3855D64BD </Id>" + 
    "     <Name xmlns=\"http://schemas.microsoft.com/crm/2006/CoreTypes\">contact</Name>" + 
    "    </Moniker2>" + 
    "    <RelationshipName>new_contract_contact</RelationshipName>" + 
    "   </Request>" + 
    "  </Execute>" + 
    " </soap:Body>" + 
    "</soap:Envelope>" + 
    "";
    
    var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
    
    xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
    xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute");
    xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
    xmlHttpRequest.send(xml);
    
    var resultXml = xmlHttpRequest.responseXML;
    

    above is java script code for this ..Please check out following article which explains how to create M:M relationship in CRM.

    http://blogs.msdn.com/crm/archive/2008/02/14/crm-4-0-relationships-explained.aspx

     

    Hope this helps..

     

     

    Monday, July 12, 2010 2:17 PM
  • I look link, and not find conversion tool. : \
    Tuesday, July 13, 2010 4:34 AM
  • hmmm, you need to download this from below URL (Click on download option from left side)

    http://www.stunnware.com/crm2/topic.aspx?id=JSWebService

     


    Mahain
    Tuesday, July 13, 2010 4:41 AM
    Moderator
  • Yes Mayank! thanks for XML.

    I use it for associate two record. Server return error message:

    0x80040216 An unexpected error occurred. Platform.

    You know this problem?

    PS:

    If in ID fields insert random ID, then server return message: contract "XXXXXX-XXX-XXX" not present. Request semi-work.

    Tuesday, July 13, 2010 4:42 AM
  • Ouuuh.   Sorry.  I raplace C# code to code of AssociateRequest, and tool return JS code + XML source.

    Thanks. Now all work.

    I cut firs symbol of contract GUID in my JavaScript code. Now all fixed.

     

    Thanks Mahender.

    Tuesday, July 13, 2010 5:39 AM