locked
"Cannot Insert Duplicate Key" when creating duplicated appointment in CRM Dynamics with SOAP

    Domanda

  • Hi all,

    I'm trying to create some appointments with the api SOAP but I have a big problem. When i try to fill the field "Mandatory Participants" (requiredattendees), I can create the appointment.

    But If I try to create another appointment with the same data in Mandatory Participants, I received a SOAP error message : IOrganizationServiceCreateOrganizationServiceFaultFaultFaultMessage: Cannot insert duplicate key

    There is my SOAP : 

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns3:Create xmlns="http://schemas.datacontract.org/2004/07/System.Collections.Generic" xmlns:ns2="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:ns3="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:ns4="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:ns5="http://schemas.microsoft.com/crm/2011/Contracts" xmlns:ns6="http://schemas.datacontract.org/2004/07/Microsoft.Crm.Sdk.Messages" xmlns:ns7="http://schemas.microsoft.com/xrm/2011/Metadata" xmlns:ns8="http://schemas.microsoft.com/xrm/2013/Metadata" xmlns:ns9="http://schemas.datacontract.org/2004/07/Microsoft.Xrm.Sdk" xmlns:ns10="http://schemas.microsoft.com/xrm/2011/Metadata/Query" xmlns:ns11="http://schemas.microsoft.com/xrm/2012/Contracts" xmlns:ns12="http://schemas.microsoft.com/2003/10/Serialization/"><ns3:entity><ns2:Attributes><ns2:KeyValuePairOfstringanyType><key>subject</key><value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">Test Participant</value></ns2:KeyValuePairOfstringanyType><ns2:KeyValuePairOfstringanyType><key>regardingobjectid</key><value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:EntityReference"><ns2:Id>2a17b598-f91e-e411-86fb-005056be1bbb</ns2:Id><ns2:LogicalName>account</ns2:LogicalName><ns2:Name xsi:nil="true"/></value></ns2:KeyValuePairOfstringanyType><ns2:KeyValuePairOfstringanyType><key>ownerid</key><value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:EntityReference"><ns2:Id>30153d17-9a6b-e711-b12b-005056921cd7</ns2:Id><ns2:LogicalName>systemuser</ns2:LogicalName><ns2:Name xsi:nil="true"/></value></ns2:KeyValuePairOfstringanyType><ns2:KeyValuePairOfstringanyType><key>scheduledstart</key><value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:dateTime">2018-01-22T12:50:00+01:00</value></ns2:KeyValuePairOfstringanyType><ns2:KeyValuePairOfstringanyType><key>scheduledend</key><value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:dateTime">2018-01-22T13:50:00+01:00</value></ns2:KeyValuePairOfstringanyType><ns2:KeyValuePairOfstringanyType><key>requiredattendees</key><value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:EntityCollection"><ns2:Entities><ns2:Entity><ns2:Attributes><ns2:KeyValuePairOfstringanyType><key>partyid</key><value xsi:type="ns2:EntityReference"><ns2:Id>3badb252-a109-df11-a66a-001a6409f7c2</ns2:Id><ns2:LogicalName>contact</ns2:LogicalName><ns2:Name xsi:nil="true"/></value></ns2:KeyValuePairOfstringanyType></ns2:Attributes><ns2:EntityState xsi:nil="true"/><ns2:FormattedValues xsi:nil="true"/><ns2:Id>3badb252-a109-df11-a66a-001a6409f7c2</ns2:Id><ns2:LogicalName>activityparty</ns2:LogicalName><ns2:RelatedEntities xsi:nil="true"/></ns2:Entity><ns2:Entity><ns2:Attributes><ns2:KeyValuePairOfstringanyType><key>partyid</key><value xsi:type="ns2:EntityReference"><ns2:Id>B279B21C-1BFD-E711-BF33-005056921CD7</ns2:Id><ns2:LogicalName>account</ns2:LogicalName><ns2:Name xsi:nil="true"/></value></ns2:KeyValuePairOfstringanyType></ns2:Attributes><ns2:EntityState xsi:nil="true"/><ns2:FormattedValues xsi:nil="true"/><ns2:Id>B279B21C-1BFD-E711-BF33-005056921CD7</ns2:Id><ns2:LogicalName>activityparty</ns2:LogicalName><ns2:RelatedEntities xsi:nil="true"/></ns2:Entity><ns2:Entity><ns2:Attributes><ns2:KeyValuePairOfstringanyType><key>partyid</key><value xsi:type="ns2:EntityReference"><ns2:Id>2a17b598-f91e-e411-86fb-005056be1bbb</ns2:Id><ns2:LogicalName>account</ns2:LogicalName><ns2:Name xsi:nil="true"/></value></ns2:KeyValuePairOfstringanyType></ns2:Attributes><ns2:EntityState xsi:nil="true"/><ns2:FormattedValues xsi:nil="true"/><ns2:Id>2a17b598-f91e-e411-86fb-005056be1bbb</ns2:Id><ns2:LogicalName>activityparty</ns2:LogicalName><ns2:RelatedEntities xsi:nil="true"/></ns2:Entity></ns2:Entities><ns2:EntityName xsi:nil="true"/><ns2:MinActiveRowVersion xsi:nil="true"/><ns2:PagingCookie xsi:nil="true"/></value></ns2:KeyValuePairOfstringanyType></ns2:Attributes><ns2:EntityState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/><ns2:FormattedValues xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/><ns2:LogicalName>appointment</ns2:LogicalName><ns2:RelatedEntities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/></ns3:entity></ns3:Create></soap:Body></soap:Envelope>


     

    Anybody have an idea?

     

    Thanks!

    martedì 23 gennaio 2018 13:18

Tutte le risposte

  • Hello,

    Can you please provide code you use when you experience mentioned issue?


    Dynamics CRM/Business Solutions MVP
    Read My blog

    mercoledì 24 gennaio 2018 03:48
    Moderatore
  • Hi,

    I believe you need to be using a different Guid (ID) for creating the second appointment, otherwise its simply trying to re-create the first one.

    regards,

    Don

    martedì 30 gennaio 2018 01:44