0

几天来,我一直在把头撞在桌子上。我的创建帐户 xml 请求工作正常,但我的事件 xml 请求不起作用。

在下面,任何帮助将不胜感激。

  $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>ownerid</c:key>  
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $ownerid . '</c:value>
                            <c:key>customerid</c:key>  
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $customerid . '</c:value>
                            <c:key>subjectid</c:key>  
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $subjectid . '</c:value>
                            <c:key>title</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $title . '</c:value>
                            <c:key>new_surveyid</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_survey_id . '</c:value>
                            <c:key>new_leadsource</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_leadsource . '</c:value>
                            <c:key>new_forename</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_forename . '</c:value>
                            <c:key>new_surname</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_surname . '</c:value>
                            <c:key>new_company</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_company . '</c:value>
                            <c:key>new_email</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_email . '</c:value>
                            <c:key>new_phone</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_phone . '</c:value>
                            <c:key>new_datetravel</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_datetravel . '</c:value>
                            <c:key>new_drivername</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_drivername . '</c:value>
                            <c:key>new_punctuality_pickup</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_punctuality_pickup . '</c:value>
                            <c:key>new_punctuality_dropoff</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_punctuality_dropoff . '</c:value>
                            <c:key>new_interior</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_interior . '</c:value>
                            <c:key>new_exterior</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_exterior . '</c:value>
                            <c:key>new_courtesy</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_courtesy . '</c:value>
                            <c:key>new_appearance</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_appearance . '</c:value>
                            <c:key>new_comments</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_comments . '</c:value>
                            <c:key>new_survey_date</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_survey_date . '</c:value>
                            <c:key>new_survey_score</c:key>
                            <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $new_survey_score . '</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>
        ';
4

3 回答 3

0

我回答了我自己的问题——XML 格式不正确——主要是命名空间的问题。再加上一些 CRM 事件字段的类型问题。如果没有上面的提示,就无法做到这一点,所以谢谢大家。下面的 XML 供将来遇到困难的任何人使用。

customerid 6caff60a-f77c-e211-b2fb-d48564518ccb 帐户

                        <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>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>
于 2013-03-17T18:43:16.780 回答
0

显然我没有发现任何错误,活动跟踪并查看正在启动的错误 crm 动态。可以是一个属性有一个拼写错误。

于 2013-03-10T16:12:09.840 回答
0

这些是字符串吗?

<c:key>ownerid</c:key>  
<c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $ownerid . '</c:value>
<c:key>customerid</c:key>  
<c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $customerid . '</c:value>

如果我通过 CRM SDK 执行此操作,我将使用实体引用。

例如

Entity e = new Entity("incident");
e["customerid"] = new EntityReference("contact", contactId); //or "account", accountId
e["ownerid"] = new EntityReference("systemuser", userId);
service.Create(e);
于 2013-03-11T11:06:23.153 回答