简体   繁体   English

通过SOAP从Dynamics CRM 2011获取更新的记录

[英]Get updated records from Dynamics CRM 2011 via SOAP

We're writing a web-frontend for at Dynamics CRM 2011 system, using PHP and SOAP (NuSOAP). 我们正在使用PHP和SOAP(NuSOAP)在Dynamics CRM 2011系统上编写Web前端。 In the process of doing so we need to retrieve entities that has been updated since our last import. 在此过程中,我们需要检索自上次导入以来已更新的实体。

I've looked around the existing CRM Frontend, to see if anything there might give a hint as what to add as criteria, but to no avail. 我环顾了现有的CRM前端,以查看是否有任何提示可以作为要添加的条件,但无济于事。

The xml for a standard query looks like this: 标准查询的xml如下所示:

<RetrieveMultiple xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
<query xmlns:q1="http://schemas.microsoft.com/crm/2006/Query" xsi:type="q1:QueryExpression">
    <q1:EntityName>new_arrangement</q1:EntityName>
    <q1:ColumnSet xsi:type="q1:ColumnSet">
        <q1:Attributes>
            <q1:Attribute>subject</q1:Attribute>
            <q1:Attribute>activitytypecode</q1:Attribute>
            <q1:Attribute>regardingobjectid</q1:Attribute>
            <q1:Attribute>scheduledstart</q1:Attribute>
            <q1:Attribute>scheduledend</q1:Attribute>
        </q1:Attributes>
    </q1:ColumnSet>
    <q1:Criteria>
        <q1:FilterOperator>And</q1:FilterOperator>
            <q1:Condition>
                <q1:AttributeName>statecode</q1:AttributeName>
                <q1:Operator>Equal</q1:Operator>
                <q1:Values>
                    <q1:Value xsi:type="xsd:string">Open</q1:Value>
                </q1:Values>
            </q1:Condition>
        </q1:Conditions>
    </q1:Criteria>
    <q1:Orders>
        <q1:Order>
            <q1:AttributeName>subject</q1:AttributeName>
            <q1:OrderType>Ascending</q1:OrderType>
        </q1:Order>
    </q1:Orders>
    <q1:Distinct>false</q1:Distinct>
    <q1:PageInfo>
        <q1:PageNumber>1</q1:PageNumber>
        <q1:Count>20</q1:Count>
    </q1:PageInfo>
</query>

So I'm looking for help with regards to which attribute I should add as a Condition. 因此,我正在寻求有关应添加为条件的属性的帮助。

If your application can remember the date and time of the last import, then you should be able to get all the new records by checking the Modified On field, I believe every entity has it. 如果您的应用程序可以记住上一次导入的日期和时间,那么您应该能够通过选中Modified On字段来获取所有新记录,我相信每个实体都可以。

I think you will want a query like this (but in XML of course). 我认为您将需要这样的查询(但当然要使用XML)。

DateTime lastImportDate = ...;

QueryExpression q = new QueryExpression("contact");
q.Criteria.FilterOperator = LogicalOperator.And;
q.Criteria.AddCondition(new ConditionExpression("statecode", ConditionOperator.Equal, "Open"));
q.Criteria.AddCondition(new ConditionExpression("modifiedon", ConditionOperator.GreaterThan, lastImportDate);

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

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