views:

946

answers:

2

So it seems using FetchXML doesn't return a column if there is no data held for it in CRM.

For example:

<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>

However the returned XML is as follows

<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>[email protected]</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>[email protected]</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>

The 2nd record has no jobtitle and neither of the records has a mobilephone number for example. This is making binding these to data controls tricky.

So basically my question is, is it possible to force CRM to return these fields with blank or null values?

+2  A: 

In short, no.

I don't know the specifics of your binding situation, but could you just have a custom model class that you populate with your fetch results, and then bind to that as opposed to binding to the XML?

Matt
I did end up going this route and adding required columns if they weren't returned in the fetch.
Fishcake
+1  A: 

The other option is to not use the FetchXML piece of the API and fetch the strongly typed BusinessEntity records using RetrieveMultiple.

brendan