微软CRM 4.0。FetchXML返回列(即使为空)

微软CRM 4.0。FetchXML返回列(即使为空),xml,dynamics-crm,dynamics-crm-4,Xml,Dynamics Crm,Dynamics Crm 4,因此,如果CRM中没有为其保存的数据,那么使用FetchXML似乎不会返回列 例如: <fetch mapping="logical" count="50"> <entity name="contact"> <attribute name="contactid" /> <attribute name="emailaddress1" /> <attribute name="firstname" /> <

因此,如果CRM中没有为其保存的数据,那么使用FetchXML似乎不会返回列

例如:

<fetch mapping="logical" count="50">
<entity name="contact">
    <attribute name="contactid" />
    <attribute name="emailaddress1" />
    <attribute name="firstname" />
    <attribute name="jobtitle" />
    <attribute name="lastname" />
    <attribute name="mobilephone" />
    <attribute name="parentcustomerid" />
    <attribute name="telephone1" />
    <filter>
        <condition attribute="parentcustomerid" operator="eq" value="94bf630f-b364-de11-8f1d-001cc02e75b4" />
    </filter>
</entity>

但是,返回的XML如下所示

<resultset morerecords="0" paging-cookie="&lt;cookie page=&quot;1&quot;&gt;&lt;contactid last=&quot;{86805DB5-E06B-DE11-81EE-001CC02E75B4}&quot; first=&quot;{7CBC9B9A-E06B-DE11-81EE-001CC02E75B4}&quot; /&gt;&lt;/cookie&gt;">
<result>
    <contactid>{7CBC9B9A-E06B-DE11-81EE-001CC02E75B4}</contactid>
    <emailaddress1>tom@xxx.org.uk</emailaddress1>
    <firstname>tommy</firstname>
    <jobtitle>Dude</jobtitle>
    <lastname>Smith</lastname>
    <parentcustomerid yomi="" name="Tom's bike shoppe" dsc="0" type="1">{94BF630F-B364-DE11-8F1D-001CC02E75B4}</parentcustomerid>
</result>
<result>
    <contactid>{86805DB5-E06B-DE11-81EE-001CC02E75B4}</contactid>
    <emailaddress1>jason@xxx.org.uk</emailaddress1>
    <firstname>jason</firstname>
    <lastname>Finch</lastname>
    <parentcustomerid yomi="" name="Tom's bike shoppe" dsc="0" type="1">{94BF630F-B364-DE11-8F1D-001CC02E75B4}</parentcustomerid>
</result>

{7CBC9B9A-E06B-DE11-81EE-001CC02E75B4}
tom@xxx.org.uk
汤米
伙计
史密斯
{94BF630F-B364-DE11-8F1D-001CC02E75B4}
{86805DB5-E06B-DE11-81EE-001CC02E75B4}
jason@xxx.org.uk
杰森
雀科小鸟
{94BF630F-B364-DE11-8F1D-001CC02E75B4}

例如,第二条记录没有职务,两条记录都没有手机号码。这使得将这些绑定到数据控件变得棘手

所以基本上我的问题是,有没有可能强制CRM以空白或空值返回这些字段?

简言之,没有


我不知道绑定情况的具体情况,但您是否可以使用获取结果填充一个自定义模型类,然后绑定到它,而不是绑定到XML?

另一个选项是不使用API的FetchXML片段,而是使用来获取强类型的BusinessEntity记录。

我确实走了这条路,如果在获取过程中没有返回所需的列,就添加它们。