简体   繁体   English

Dynamics CRM创建事件

[英]Dynamics CRM create incident

Im trying to create an incident on the Dynamics CRM through their API. 我试图通过其API在Dynamics CRM上创建事件。

Im successfully authing however when I try to create the incident using: 我尝试使用以下方式创建事件时,我成功进行了身份验证:

    $accountsRequest = EntityUtils::getCreateCRMSoapHeader($CRMURL, $securityData).
'
      <s:Body>
            <Create xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
            <entity xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <b:Attributes xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
                    <b:KeyValuePairOfstringanyType>                         
                        <c:key>title</c:key>
                        <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">Its a sunday web case - second</c:value>
                    </b:KeyValuePairOfstringanyType>                     
                </b:Attributes>
                <b:EntityState i:nil="true"/>
                <b:FormattedValues xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
                <b:Id>'.$accountId.'</b:Id>
                <b:LogicalName>incident</b:LogicalName>
                <b:RelatedEntities xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
            </entity>
            </Create>
        </s:Body>
    </s:Envelope>
    ';

$accountId looks like this:
dabc10e9-df02-e611-80d9-5065f38a9b01

I'm getting the following error: 我收到以下错误:

You should specify a parent contact or account.-2147204080 You should specify a parent contact or account.2016-04-15T07:59:11.6607106Z-2147204080 You should specify a parent contact or account.2016-04-15T07:59:11.6607106Z 您应该指定一个父级联系人或帐户.-2147204080您应该指定一个父级联系人或帐户.2016-04-15T07:59:11.6607106Z-2147204080您应该指定一个父级联系人或帐户.2016-04-15T07:59:11.6607106 ž

Any ideas what I'm missing? 有什么想法我想念的吗?

Edit Updated and tried this: 编辑更新,并尝试这样做:

'
      <s:Body>
            <Create xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
            <entity xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <b:Attributes xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
                    <b:KeyValuePairOfstringanyType>                         
                        <c:key>title</c:key>
                        <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">Its a sunday web case - second</c:value>
                    </b:KeyValuePairOfstringanyType>
                    <b:KeyValuePairOfstringanyType>
                        <c:key>customerid</c:key>
                        <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">19622e39-e502-e611-80da-5065f38ada41</c:value>
                    </b:KeyValuePairOfstringanyType>                                                              
                </b:Attributes>
                <b:EntityState i:nil="true"/>
                <b:FormattedValues xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
                <b:Id>00000000-0000-0000-0000-000000000000</b:Id>
                <b:LogicalName>incident</b:LogicalName>
                <b:RelatedEntities xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>                    
            </entity>
            </Create>
        </s:Body>
    </s:Envelope>
    ';

But still same error 但是还是一样的错误

Edit #2, Also tried: 编辑#2,也尝试过:

'
      <s:Body>
            <Create xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
            <entity xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <b:Attributes xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
                    <b:KeyValuePairOfstringanyType>                         
                        <c:key>title</c:key>
                        <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">Its a sunday web case - second</c:value>
                    </b:KeyValuePairOfstringanyType>
                    <b:KeyValuePairOfstringanyType>
                        <c:key>customerid</c:key>
                        <b:value i:type="a:EntityReference">
                           <a:Id>19622e39-e502-e611-80da-5065f38ada41</a:Id>
                           <a:LogicalName>account</a:LogicalName>
                           <a:Name i:nil="true" />
                        </b:value>
                    </b:KeyValuePairOfstringanyType>                                                              
                </b:Attributes>
                <b:EntityState i:nil="true"/>
                <b:FormattedValues xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
                <b:Id>00000000-0000-0000-0000-000000000000</b:Id>
                <b:LogicalName>incident</b:LogicalName>
                <b:RelatedEntities xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>                    
            </entity>
            </Create>
        </s:Body>
    </s:Envelope>
    ';

And am getting error: 并出现错误:

DeserializationFailedThe formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:entity . DeserializationFailed格式化程序尝试反序列化消息时引发异常:尝试反序列化参数http://schemas.microsoft.com/xrm/2011/Contracts/Services:entity时出错。 The InnerException message was 'Error in line 68 position 57. 'EndElement' 'KeyValuePairOfstringanyType' from namespace ' http://schemas.microsoft.com/xrm/2011/Contracts ' is not expected. InnerException消息为“第68行的位置57错误。”不应来自名称空间“ http://schemas.microsoft.com/xrm/2011/Contracts ”的“ EndElement”,“ KeyValuePairOfstringanyType”。 Expecting element 'value'.'. 期望元素“值”。 Please see InnerException for more details. 有关更多详细信息,请参见InnerException。

It looks like you might be trying to put an account id value into the Id attribute. 看来您可能正在尝试将帐户ID值放入Id属性。 The Id attribute refers to the Id of the incident...it's better to let CRM generate ids for you, so don't supply anything for the Id attribute (unless you are purposely trying to set the id of the new incident). Id属性是指事件的ID ...最好让CRM为您生成ID,所以不要为Id属性提供任何信息(除非您有意尝试设置新事件的ID)。

The error is referring to the customerid attribute which is of type EntityReference. 错误是指类型为EntityReference的customerid属性。 EntityReferences have Id and LogicalName properties. EntityReferences具有Id和LogicalName属性。 Put your $accountId value into the customerid.Id, and make customerid.LogicalName be "account". 将您的$accountId值放入customerid.Id,并使customerid.LogicalName为“ account”。 EntityReferences also have Name property, but you don't have to supply that. EntityReferences也具有Name属性,但是您不必提供该属性。

Your edit #2 looks like it might have some namespacing issues. 您的编辑#2看起来可能存在一些命名空间问题。 Try this: 尝试这个:

<b:KeyValuePairOfstringanyType>
    <c:key>customerid</c:key>
    <c:value i:type="b:EntityReference">
       <b:Id>19622e39-e502-e611-80da-5065f38ada41</b:Id>
       <b:LogicalName>account</b:LogicalName>
       <b:Name i:nil="true" />
    </c:value>
</b:KeyValuePairOfstringanyType>      

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM